Class: Hardware::Enum
- Inherits:
-
Object
- Object
- Hardware::Enum
- Defined in:
- lib/hardware/enum.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type) ⇒ Enum
constructor
A new instance of Enum.
- #inspect ⇒ Object
Constructor Details
#initialize(type) ⇒ Enum
Returns a new instance of Enum.
3 4 5 |
# File 'lib/hardware/enum.rb', line 3 def initialize(type) @type = type end |
Class Method Details
.method_missing(method) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/hardware/enum.rb', line 9 def self.method_missing(method) begin self.send('class_variable_get',"@@#{method}") rescue raise "Enum constant '#{method}' not defined in #{self}" end end |
.values(*values) ⇒ Object
16 17 18 |
# File 'lib/hardware/enum.rb', line 16 def self.values(*values) values.each{|value| send('class_variable_set',"@@#{value}", new(value.to_s))} end |
Instance Method Details
#inspect ⇒ Object
6 7 8 |
# File 'lib/hardware/enum.rb', line 6 def inspect return "#{self.class.name}.#{@type}" end |