Class: Fit4Ruby::Metrics

Inherits:
FitDataRecord show all
Defined in:
lib/fit4ruby/Metrics.rb

Overview

The Metrics object is a FIT file class. It’s a top-level object that holds all references to other FIT records that are part of the FIT file. Each of the objects it references are direct equivalents of the message record structures used in the FIT file.

This is not part of the officially documented FIT API. Names may change in the future if the real Garmin names get known.

Constant Summary

Constants inherited from FitDataRecord

FitDataRecord::RecordOrder

Constants included from BDFieldNameTranslator

BDFieldNameTranslator::BD_DICT

Instance Attribute Summary collapse

Attributes inherited from FitDataRecord

#message, #timestamp

Instance Method Summary collapse

Methods inherited from FitDataRecord

#<=>, #==, #export, #get, #get_as, #get_unit_by_name, #set, #set_field_values, #write

Methods included from BDFieldNameTranslator

#to_bd_field_name

Methods included from Converters

#conversion_factor, #fit_time_to_time, #secsToDHMS, #secsToHM, #secsToHMS, #speedToPace, #time_to_fit_time

Constructor Details

#initialize(field_values = {}) ⇒ Metrics

Create a new Metrics object.

Parameters:

  • field_values (Hash) (defaults to: {})

    A Hash that provides initial values for certain fields of the FitDataRecord.



35
36
37
38
39
40
41
42
43
44
# File 'lib/fit4ruby/Metrics.rb', line 35

def initialize(field_values = {})
  super('metrics')

  @field_descriptions = []

  @file_id = FileId.new
  @device_infos = []
  @file_creator = nil
  @training_statuses = []
end

Instance Attribute Details

#device_infosObject

Returns the value of attribute device_infos.



30
31
32
# File 'lib/fit4ruby/Metrics.rb', line 30

def device_infos
  @device_infos
end

#field_descriptionsObject

Returns the value of attribute field_descriptions.



30
31
32
# File 'lib/fit4ruby/Metrics.rb', line 30

def field_descriptions
  @field_descriptions
end

#file_creatorObject

Returns the value of attribute file_creator.



30
31
32
# File 'lib/fit4ruby/Metrics.rb', line 30

def file_creator
  @file_creator
end

#file_idObject

Returns the value of attribute file_id.



30
31
32
# File 'lib/fit4ruby/Metrics.rb', line 30

def file_id
  @file_id
end

Instance Method Details

#checkObject

Perform some basic logical checks on the object and all references sub objects. Any errors will be reported via the Log object.



48
49
# File 'lib/fit4ruby/Metrics.rb', line 48

def check
end

#new_fit_data_record(record_type, field_values = {}) ⇒ Object

Create a new FitDataRecord.

Parameters:

  • record_type (String)

    Type that identifies the FitDataRecord derived class to create.

  • field_values (Hash) (defaults to: {})

    A Hash that provides initial values for certain fields of the FitDataRecord.

Returns:

  • FitDataRecord



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fit4ruby/Metrics.rb', line 57

def new_fit_data_record(record_type, field_values = {})
  case record_type
  when 'file_id'
    @file_id = (record = FileId.new(field_values))
  when 'file_creator'
    @software = (record = FileCreator.new(field_values))
  when 'device_info'
    @device_infos << (record = DeviceInfo.new(field_values))
  when 'training_status'
    @training_statuses << (record = TrainingStatus.new(field_values))
  else
    record = nil
  end

  record
end