Class: TrimetterArrival
- Inherits:
-
Object
- Object
- TrimetterArrival
- Defined in:
- lib/trimetter.rb
Overview
A pure-data class to bundle a number of arrival properties
Instance Attribute Summary collapse
-
#arrival_time ⇒ Object
Returns the value of attribute arrival_time.
-
#arriving_in_minutes ⇒ Object
Returns the value of attribute arriving_in_minutes.
-
#location ⇒ Object
Returns the value of attribute location.
-
#route ⇒ Object
Returns the value of attribute route.
-
#sign_full ⇒ Object
Returns the value of attribute sign_full.
-
#sign_short ⇒ Object
Returns the value of attribute sign_short.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize ⇒ TrimetterArrival
constructor
A new instance of TrimetterArrival.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ TrimetterArrival
Returns a new instance of TrimetterArrival.
31 32 33 34 35 36 37 38 39 |
# File 'lib/trimetter.rb', line 31 def initialize() @route = '' @location = 0 @arrival_time = Time.at(0) @arriving_in_minutes = 0 @status = :invalid # can be invalid, estimated, scheduled, delayed, canceled, error @sign_full = 0 @sign_short = 0 end |
Instance Attribute Details
#arrival_time ⇒ Object
Returns the value of attribute arrival_time.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def arrival_time @arrival_time end |
#arriving_in_minutes ⇒ Object
Returns the value of attribute arriving_in_minutes.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def arriving_in_minutes @arriving_in_minutes end |
#location ⇒ Object
Returns the value of attribute location.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def location @location end |
#route ⇒ Object
Returns the value of attribute route.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def route @route end |
#sign_full ⇒ Object
Returns the value of attribute sign_full.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def sign_full @sign_full end |
#sign_short ⇒ Object
Returns the value of attribute sign_short.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def sign_short @sign_short end |
#status ⇒ Object
Returns the value of attribute status.
30 31 32 |
# File 'lib/trimetter.rb', line 30 def status @status end |
Instance Method Details
#to_s ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/trimetter.rb', line 41 def to_s() result = '#' result << "#{@route} \"#{@sign_short}\"/\"#{@sign_full}\"" result << " @ StopID #{@location}, " if :error == @status result << "[error]" elsif :canceled == @status result << "[canceled]" elsif :invalid == @status result << "[uninitialized]" elsif :estimated == @status result << "Arriving in #{@arriving_in_minutes} minute#{@arriving_in_minutes == 1 ? '' : 's'}" elsif :scheduled == @status result << "Arriving in #{@arriving_in_minutes} minute#{@arriving_in_minutes == 1 ? '' : 's'}???" elsif :delayed == @status result << "Arriving @ #{@arrival_time.strftime('%I:%M%p')}" else result << "YOU SHOULDN'T BE SEEING THIS" end return result end |