Class: Homerun

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/yabo_tracker/homerun.rb

Constant Summary

Constants included from Helpers

Helpers::BASE_URL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

build_base_url, generate_nokogiri_html

Constructor Details

#initialize(homerun_nokogiri_row) ⇒ Homerun

Returns a new instance of Homerun.



10
11
12
13
# File 'lib/yabo_tracker/homerun.rb', line 10

def initialize(homerun_nokogiri_row)
  @horizontal_angle = homerun_nokogiri_row.search('td:nth-of-type(14) span').text.to_f
  @true_distance    = homerun_nokogiri_row.search('td:nth-of-type(19) span').text.to_i
end

Instance Attribute Details

#horizontal_angleObject (readonly)

Returns the value of attribute horizontal_angle.



6
7
8
# File 'lib/yabo_tracker/homerun.rb', line 6

def horizontal_angle
  @horizontal_angle
end

#true_distanceObject (readonly)

Returns the value of attribute true_distance.



6
7
8
# File 'lib/yabo_tracker/homerun.rb', line 6

def true_distance
  @true_distance
end

Class Method Details

.homers_for_id(id) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/yabo_tracker/homerun.rb', line 15

def self.homers_for_id(id)
  html = Helpers.generate_nokogiri_html(Helpers.build_base_url(id))
  rows = html.search('table.forumline:last-of-type tr')[4..-1]
  rows.map do |row|
    Homerun.new(row)
  end
end