Class: Lap

Inherits:
Object
  • Object
show all
Includes:
DateTimeParser
Defined in:
lib/lap.rb

Constant Summary collapse

TYPES =
{
  :start => 0,
  :lap   => 1,
  :stop  => 2
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DateTimeParser

#read_date_time

Constructor Details

#initialize(data = nil) ⇒ Lap

Returns a new instance of Lap.



13
14
15
# File 'lib/lap.rb', line 13

def initialize(data = nil)
  read_data(data) if data
end

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



9
10
11
# File 'lib/lap.rb', line 9

def distance
  @distance
end

#positionObject

Returns the value of attribute position.



9
10
11
# File 'lib/lap.rb', line 9

def position
  @position
end

#straight_line_distanceObject

Returns the value of attribute straight_line_distance.



9
10
11
# File 'lib/lap.rb', line 9

def straight_line_distance
  @straight_line_distance
end

#timeObject (readonly)

Returns the value of attribute time.



8
9
10
# File 'lib/lap.rb', line 8

def time
  @time
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/lap.rb', line 8

def type
  @type
end

Instance Method Details

#is_of_type?(*types) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/lap.rb', line 22

def is_of_type?(*types)
  types.any?{|t| type == TYPES[t]}
end

#read_data(data) ⇒ Object



17
18
19
20
# File 'lib/lap.rb', line 17

def read_data(data)
  @time = read_date_time(data)
  @type = BinData::Uint8be.read(data)
end