Sha256: 053ad5c855d9b9613c4a35c8d32944b6d2bdd133fde4afc5e54ffabe09d38303

Contents?: true

Size: 589 Bytes

Versions: 2

Compression:

Stored size: 589 Bytes

Contents

class Route
  attr_accessor :id, :link, :name

  def initialize(name, link)
    @name, @link = name, link.gsub('direction', 'stops')
    @id = @link.split("/")[-2]
  end

  # Returns array of instantiated Stops associated with Route
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pennride-0.1.1 lib/pennride/route.rb
pennride-0.1 lib/pennride/route.rb