Class: EacRubyUtils::Enum::Value
- Includes:
- Comparable
- Defined in:
- lib/eac_ruby_utils/enum.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #apply ⇒ Object
- #class_method_name ⇒ String
- #constant_name ⇒ String
-
#initialize(klass, key, args, &block) ⇒ Value
constructor
A new instance of Value.
- #value ⇒ Object
Constructor Details
#initialize(klass, key, args, &block) ⇒ Value
Returns a new instance of Value.
43 44 45 46 47 48 |
# File 'lib/eac_ruby_utils/enum.rb', line 43 def initialize(klass, key, args, &block) @klass = klass @key = ::EacRubyUtils::Inflector.variableize(key.to_s).to_sym @args = args @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
41 42 43 |
# File 'lib/eac_ruby_utils/enum.rb', line 41 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
41 42 43 |
# File 'lib/eac_ruby_utils/enum.rb', line 41 def block @block end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
41 42 43 |
# File 'lib/eac_ruby_utils/enum.rb', line 41 def key @key end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
41 42 43 |
# File 'lib/eac_ruby_utils/enum.rb', line 41 def klass @klass end |
Instance Method Details
#<=>(other) ⇒ Object
50 51 52 |
# File 'lib/eac_ruby_utils/enum.rb', line 50 def <=>(other) key <=> other.key end |
#apply ⇒ Object
54 55 56 57 58 59 |
# File 'lib/eac_ruby_utils/enum.rb', line 54 def apply define_constant define_class_method self end |
#class_method_name ⇒ String
62 63 64 |
# File 'lib/eac_ruby_utils/enum.rb', line 62 def class_method_name key.to_s end |
#constant_name ⇒ String
67 68 69 |
# File 'lib/eac_ruby_utils/enum.rb', line 67 def constant_name class_method_name.upcase end |
#value ⇒ Object
71 72 73 |
# File 'lib/eac_ruby_utils/enum.rb', line 71 def value @value ||= uncached_value end |