Class: BostonMarathon::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/boston_marathon/result.rb

Constant Summary collapse

ATTR_TRANSLATE =
{
  'm/f' => 'gender',
  'st' => 'state',
  'ctry' => 'country',
  'ctz' => 'citizenship',
  'proj. time' => 'projected_time',
  'offl. time' => 'time',
  'overall' => 'place',
  'gender' => 'gender_place',
  'division' => 'division_place'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, infogrid) ⇒ Result

Returns a new instance of Result.



19
20
21
22
23
# File 'lib/boston_marathon/result.rb', line 19

def initialize(header, infogrid)
  @header = header        # athlete bib, name, age, gender, city, state, country
  @infogrid = infogrid    # splits and finish info (pace, time, place, gender_place, division_place)
  set_attrs
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/boston_marathon/result.rb', line 25

def method_missing(method, *args)
  m = method.to_s.downcase
  if @attrs.has_key? m
    @attrs[m]
  else
    super
  end
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



17
18
19
# File 'lib/boston_marathon/result.rb', line 17

def attrs
  @attrs
end