lib/fit4ruby/Activity.rb
def new_fit_data_record(record_type, field_values = {})
      case record_type
      when 'file_id'
        @file_id = (record = FileId.new(field_values))
      when 'field_description'
        @field_descriptions << (record = FieldDescription.new(field_values))
      when 'developer_data_id'
        @developer_data_ids << (record = DeveloperDataId.new(field_values))
      when 'epo_data'
        @epo_data = (record = EPO_Data.new(field_values))
      when 'file_creator'
        @file_creator = (record = FileCreator.new(field_values))
      when 'device_info'
        @device_infos << (record = DeviceInfo.new(field_values))
      when 'sensor_settings'
        @sensor_settings << (record = SensorSettings.new(field_values))
      when 'data_sources'
        @data_sources << (record = DataSources.new(field_values))
      when 'user_data'
        @user_data << (record = UserData.new(field_values))
      when 'user_profile'
        @user_profiles << (record = UserProfile.new(field_values))
      when 'physiological_metrics'
        @physiological_metrics <<
          (record = PhysiologicalMetrics.new(field_values))
      when 'event'
        @events << (record = Event.new(field_values))
      when 'session'
        unless @cur_lap_records.empty?
          # Copy selected fields from section to lap.
          lap_field_values = {}
          [ :timestamp, :sport ].each do |f|
            lap_field_values[f] = field_values[f] if field_values.include?(f)
          end
          # Ensure that all previous records have been assigned to a lap.
          record = create_new_lap(lap_field_values)
        end
        @num_sessions += 1
        @sessions << (record = Session.new(@cur_session_laps, @lap_counter,
                                           field_values))
        @cur_session_laps = []
      when 'lap'
        record = create_new_lap(field_values)
      when 'record'
        @cur_lap_records << (record = Record.new(field_values))
        @records << record
      when 'hrv'
        @hrv << (record = HRV.new(field_values))
      when 'heart_rate_zones'
        @heart_rate_zones << (record = HeartRateZones.new(field_values))
      when 'personal_records'
        @personal_records << (record = PersonalRecords.new(field_values))
      else
        record = nil
      end

      record
    end
def new_fit_data_record(record_type, field_values = {})
      case record_type
      when 'file_id'
        @file_id = (record = FileId.new(field_values))
      when 'field_description'
        @field_descriptions << (record = FieldDescription.new(field_values))
      when 'developer_data_id'
        @developer_data_ids << (record = DeveloperDataId.new(field_values))
      when 'epo_data'
        @epo_data = (record = EPO_Data.new(field_values))
      when 'file_creator'
        @file_creator = (record = FileCreator.new(field_values))
      when 'device_info'
        @device_infos << (record = DeviceInfo.new(field_values))
      when 'sensor_settings'
        @sensor_settings << (record = SensorSettings.new(field_values))
      when 'data_sources'
        @data_sources << (record = DataSources.new(field_values))
      when 'user_data'
        @user_data << (record = UserData.new(field_values))
      when 'user_profile'
        @user_profiles << (record = UserProfile.new(field_values))
      when 'physiological_metrics'
        @physiological_metrics <<
          (record = PhysiologicalMetrics.new(field_values))
      when 'event'
        @events << (record = Event.new(field_values))
      when 'session'
        unless @cur_lap_records.empty?
          # Copy selected fields from section to lap.
          lap_field_values = {}
          [ :timestamp, :sport ].each do |f|
            lap_field_values[f] = field_values[f] if field_values.include?(f)
          end
          # Ensure that all previous records have been assigned to a lap.
          record = create_new_lap(lap_field_values)
        end
        @num_sessions += 1
        @sessions << (record = Session.new(@cur_session_laps, @lap_counter,
                                           field_values))
        @cur_session_laps = []
      when 'lap'
        record = create_new_lap(field_values)
      when 'record'
        @cur_lap_records << (record = Record.new(field_values))
        @records << record
      when 'hrv'
        @hrv << (record = HRV.new(field_values))
      when 'heart_rate_zones'
        @heart_rate_zones << (record = HeartRateZones.new(field_values))
      when 'personal_records'
        @personal_records << (record = PersonalRecords.new(field_values))
      else
        record = nil
      end

      record
    end
Check if the current Activity is equal to the passed Activity.
 @param a [Activity] Activity to compare this Activity with.
 @return [TrueClass/FalseClass] true if both Activities are equal,
 otherwise false.
 Create a new FitDataRecord.
 @param record_type [String] Type that identifies the FitDataRecord
        derived class to create.
 @param field_values [Hash] A Hash that provides initial values for
        certain fields of the FitDataRecord.
 @return FitDataRecord