Class: TrimetterArrival

Inherits:
Object
  • Object
show all
Defined in:
lib/trimetter.rb

Overview

A pure-data class to bundle a number of arrival properties

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTrimetterArrival

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_timeObject

Returns the value of attribute arrival_time.



30
31
32
# File 'lib/trimetter.rb', line 30

def arrival_time
  @arrival_time
end

#arriving_in_minutesObject

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

#locationObject

Returns the value of attribute location.



30
31
32
# File 'lib/trimetter.rb', line 30

def location
  @location
end

#routeObject

Returns the value of attribute route.



30
31
32
# File 'lib/trimetter.rb', line 30

def route
  @route
end

#sign_fullObject

Returns the value of attribute sign_full.



30
31
32
# File 'lib/trimetter.rb', line 30

def sign_full
  @sign_full
end

#sign_shortObject

Returns the value of attribute sign_short.



30
31
32
# File 'lib/trimetter.rb', line 30

def sign_short
  @sign_short
end

#statusObject

Returns the value of attribute status.



30
31
32
# File 'lib/trimetter.rb', line 30

def status
  @status
end

Instance Method Details

#to_sObject



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