Class: Fit::File::Type
- Inherits:
-
Object
- Object
- Fit::File::Type
- Defined in:
- lib/fit/file/type.rb
Constant Summary collapse
- @@types =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type) ⇒ Type
constructor
A new instance of Type.
- #value(val) ⇒ Object
Constructor Details
#initialize(type) ⇒ Type
Returns a new instance of Type.
13 14 15 |
# File 'lib/fit/file/type.rb', line 13 def initialize(type) @type = type end |
Class Method Details
.get_type(name) ⇒ Object
7 8 9 10 11 |
# File 'lib/fit/file/type.rb', line 7 def self.get_type(name) return @@types[name] if @@types.has_key? name type = Types.get_type_definition name @@types[name] = type ? new(type) : nil end |
Instance Method Details
#value(val) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fit/file/type.rb', line 17 def value(val) return nil unless is_valid(val) if @type.has_key? :method Types.send(@type[:method], val, @type[:values], @type[:parameters]) else values = @type[:values] value = values[val] if values return value unless value.nil? val end end |