RAA - enum-const

enum-const / 0.1

Short description: Help set enumerative constant
Category: Library/Language
Status: experimental
Created: 2007-04-03 13:45:19 GMT
Last update: 2007-04-03 13:45:19 GMT
Owner: Bookmarker (Projects of this owner)
Homepage: http://d.hatena.ne.jp/Bookmarker/20070402/1175494823
Download: not available
License: Ruby's
Dependency:
None
Description:
Help set enumerative constant

example:
  class Foo
    enum_const_set %w[
      XX_A
      XX_B
      XX_C
    ]
  end
  
  p Foo::XX_A	# => 0
  p Foo::XX_B	# => 1
  p Foo::XX_C	# => 2
  
  class Bar
    enum_const_set_bit %w[
      XX_A
      XX_B
      XX_C
    ]
  end
  
  p Bar::XX_A	# => 1 = 0b0001
  p Bar::XX_B	# => 2 = 0b0010
  p Bar::XX_C	# => 4 = 0b0100

Edit this project (for project owner)

back to RAA top