Class: Fitreader::MessageType

Inherits:
Object
  • Object
show all
Defined in:
lib/fitreader/message_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ MessageType

Returns a new instance of MessageType.



6
7
8
9
10
# File 'lib/fitreader/message_type.rb', line 6

def initialize(definition)
  @definition = definition
  @records = []
  @undefined_records = []
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



3
4
5
# File 'lib/fitreader/message_type.rb', line 3

def definition
  @definition
end

#recordsObject (readonly)

Returns the value of attribute records.



3
4
5
# File 'lib/fitreader/message_type.rb', line 3

def records
  @records
end

#undefined_recordsObject

Returns the value of attribute undefined_records.



4
5
6
# File 'lib/fitreader/message_type.rb', line 4

def undefined_records
  @undefined_records
end

Instance Method Details

#error_fieldsObject



18
19
20
21
22
# File 'lib/fitreader/message_type.rb', line 18

def error_fields
  records.flatten
         .select { |x| !x.error_fields.empty? }
         .collect(&:error_fields)
end

#record_valuesObject



12
13
14
15
16
# File 'lib/fitreader/message_type.rb', line 12

def record_values
  records.flatten
         .collect { |y|y.fields.values.collect { |z| [z.name, z.value] } }
         .collect(&:to_h)
end