Class: Fit4Ruby::DumpedField

Inherits:
Object
  • Object
show all
Defined in:
lib/fit4ruby/DumpedField.rb

Overview

If the user has requested a dump of the records, this class is used to capture a subset of the field related information for the later textual dump.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_number, field_number, name, type, value) ⇒ DumpedField

Create a new field dump record.

Parameters:

  • message_number (Fixnum)

    The global message number of the message this field belongs to.

  • field_number (Fixnum)

    The number of the FIT message field

  • name (String)

    The name of the field

  • type (Symbol)

    The type of the field

  • value (String)

    A human readable dump of the field value



29
30
31
32
33
34
35
# File 'lib/fit4ruby/DumpedField.rb', line 29

def initialize(message_number, field_number, name, type, value)
  @message_number = message_number
  @field_number = field_number
  @name = name
  @type = type
  @value = value
end

Instance Attribute Details

#field_numberObject (readonly)

Returns the value of attribute field_number.



20
21
22
# File 'lib/fit4ruby/DumpedField.rb', line 20

def field_number
  @field_number
end

#message_numberObject (readonly)

Returns the value of attribute message_number.



20
21
22
# File 'lib/fit4ruby/DumpedField.rb', line 20

def message_number
  @message_number
end

Instance Method Details

#<=>(f) ⇒ Object



37
38
39
# File 'lib/fit4ruby/DumpedField.rb', line 37

def <=>(f)
  @field_number <=> f.field_number
end

#to_s(index) ⇒ Object



41
42
43
44
45
# File 'lib/fit4ruby/DumpedField.rb', line 41

def to_s(index)
  "[#{'%03d' % @message_number}:#{'%03d' % index}:" +
  "#{'%03d' % @field_number}:" +
  "#{"%-7s" % @type}] #{@name}: " + "#{@value}"
end