Class: Amtrak::TrainFetcher
- Inherits:
-
Object
- Object
- Amtrak::TrainFetcher
- Defined in:
- lib/amtrak/train_fetcher.rb
Overview
Service for getting train time HTML page from the Amtrak website
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
- #check_release ⇒ Object
- #get ⇒ Object
-
#initialize(from, to, date: nil) ⇒ TrainFetcher
constructor
A new instance of TrainFetcher.
Constructor Details
#initialize(from, to, date: nil) ⇒ TrainFetcher
Returns a new instance of TrainFetcher.
14 15 16 17 18 |
# File 'lib/amtrak/train_fetcher.rb', line 14 def initialize(from, to, date: nil) @from = from @to = to @date = date || Date.today end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
12 13 14 |
# File 'lib/amtrak/train_fetcher.rb', line 12 def date @date end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
12 13 14 |
# File 'lib/amtrak/train_fetcher.rb', line 12 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
12 13 14 |
# File 'lib/amtrak/train_fetcher.rb', line 12 def to @to end |
Class Method Details
.get(*args) ⇒ Object
8 9 10 |
# File 'lib/amtrak/train_fetcher.rb', line 8 def self.get(*args) new(*args).get end |
Instance Method Details
#check_release ⇒ Object
20 21 22 |
# File 'lib/amtrak/train_fetcher.rb', line 20 def check_release first_page.release == '6.25.02a' end |
#get ⇒ Object
24 25 26 |
# File 'lib/amtrak/train_fetcher.rb', line 24 def get JSON.parse(response.body) end |