Project

attr_enum

0.0
No commit activity in last 3 years
No release in over 3 years
Enumerated type macro for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

attr_enum¶ ↑

A class macro to define an enumeration variable. See en.wikipedia.org/wiki/Enumerated_type for more information.

Usage¶ ↑

class Card
  attr_enum :suit, %w( clubs hearts diamonds spades )
end

c = Card.new
c.suit = 'clubs'
c.suit
=> 'clubs'
c.suit = 'jack' 
=> EnumeratedTypeError, Card#suit must be one of clubs, hearts, diamonds, spades.

Installation¶ ↑

From rubyforge:

gem install attr_enum

From github:

gem install kmcd-attr_enum --source http://gems.github.com