Class: RockNRoll::Race
- Inherits:
-
Object
- Object
- RockNRoll::Race
- Defined in:
- lib/rock_n_roll/race.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#distances ⇒ Object
Returns the value of attribute distances.
-
#hashtag ⇒ Object
Returns the value of attribute hashtag.
-
#location ⇒ Object
Returns the value of attribute location.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(location = nil, url = nil) ⇒ Race
constructor
A new instance of Race.
- #race_site ⇒ Object
Constructor Details
#initialize(location = nil, url = nil) ⇒ Race
6 7 8 9 10 |
# File 'lib/rock_n_roll/race.rb', line 6 def initialize(location = nil, url = nil) @location = location @url = url @@all << self end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/rock_n_roll/race.rb', line 2 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/rock_n_roll/race.rb', line 2 def description @description end |
#distances ⇒ Object
Returns the value of attribute distances.
2 3 4 |
# File 'lib/rock_n_roll/race.rb', line 2 def distances @distances end |
#hashtag ⇒ Object
Returns the value of attribute hashtag.
2 3 4 |
# File 'lib/rock_n_roll/race.rb', line 2 def hashtag @hashtag end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/rock_n_roll/race.rb', line 2 def location @location end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/rock_n_roll/race.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/rock_n_roll/race.rb', line 20 def self.all @@all end |
.new_from_list(race) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rock_n_roll/race.rb', line 12 def self.new_from_list(race) url = race.css("h5 a").attribute("href").text if !url.end_with?("/") url += "/" end self.new(race.css("h5 a").text, url) end |
.retrieve(input) ⇒ Object
24 25 26 |
# File 'lib/rock_n_roll/race.rb', line 24 def self.retrieve(input) self.all[input.to_i - 1] end |
Instance Method Details
#race_site ⇒ Object
28 29 30 |
# File 'lib/rock_n_roll/race.rb', line 28 def race_site @race_site ||= Nokogiri::HTML(open(self.url)) end |