Method: Fit4Ruby::FitFileEntity#set_type

Defined in:
lib/fit4ruby/FitFileEntity.rb

#set_type(type) ⇒ Object

Set what kind of FIT file we are dealing with. a derivative of FitDataRecord.

Returns:

  • The Ruby object that will hold the content of the FIT file. It’s



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fit4ruby/FitFileEntity.rb', line 38

def set_type(type)
  if @top_level_record
    Log.fatal "FIT file type has already been set to " +
              "#{@top_level_record.class}"
  end
  case type
  when 4, 'activity'
    @top_level_record = Activity.new
    @type = 'activity'
  when 32, 'monitoring_b'
    @top_level_record = Monitoring_B.new
    @type = 'monitoring_b'
  else
    Log.error "Unsupported FIT file type #{type}"
    return nil
  end

  @top_level_record
end