Class: Route
- Inherits:
-
Object
- Object
- Route
- Defined in:
- lib/pennride/route.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, link) ⇒ Route
constructor
A new instance of Route.
-
#stops(link = @link) ⇒ Object
Returns array of instantiated Stops associated with Route.
Constructor Details
#initialize(name, link) ⇒ Route
Returns a new instance of Route.
4 5 6 7 |
# File 'lib/pennride/route.rb', line 4 def initialize(name, link) @name, @link = name, link.gsub('direction', 'stops') @id = @link.split("/")[-2] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/pennride/route.rb', line 2 def id @id end |
#link ⇒ Object
Returns the value of attribute link.
2 3 4 |
# File 'lib/pennride/route.rb', line 2 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/pennride/route.rb', line 2 def name @name end |
Instance Method Details
#stops(link = @link) ⇒ Object
Returns array of instantiated Stops associated with Route
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pennride/route.rb', line 10 def stops(link = @link) @stops = Wombat.crawl { base_url ROOT path link stops "xpath=//li[@class='arrow']/a[contains(@href, '/stops/')]", :iterator do name "xpath=./text()" href "xpath=./@href" end }['stops'].map { |s| Stop.new(s['name'], s['href']) } unless @stops @stops end |