Class: EasyTransilien::Stop
- Inherits:
-
Object
- Object
- EasyTransilien::Stop
- Includes:
- Comparable
- Defined in:
- lib/easy_transilien/stop.rb
Instance Attribute Summary collapse
-
#ms_stop ⇒ Object
Returns the value of attribute ms_stop.
Instance Method Summary collapse
-
#<=>(another) ⇒ Object
Comparable Stuff.
- #access_time ⇒ Object
- #name_at_stop ⇒ Object
- #station_external_code ⇒ Object
- #station_name ⇒ Object
- #stop_point_idx ⇒ Object
- #stop_time ⇒ Object
- #time ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#ms_stop ⇒ Object
Returns the value of attribute ms_stop.
4 5 6 |
# File 'lib/easy_transilien/stop.rb', line 4 def ms_stop @ms_stop end |
Instance Method Details
#<=>(another) ⇒ Object
Comparable Stuff
47 48 49 |
# File 'lib/easy_transilien/stop.rb', line 47 def <=>(another) self.time <=> another.time end |
#access_time ⇒ Object
6 7 8 |
# File 'lib/easy_transilien/stop.rb', line 6 def access_time ms_stop && ms_stop.access_time end |
#name_at_stop ⇒ Object
18 19 20 |
# File 'lib/easy_transilien/stop.rb', line 18 def name_at_stop ms_stop && ms_stop.name_at_stop end |
#station_external_code ⇒ Object
27 28 29 |
# File 'lib/easy_transilien/stop.rb', line 27 def station_external_code @station_external_code ||= ms_stop && ms_stop.stop_point.external_code end |
#station_name ⇒ Object
14 15 16 |
# File 'lib/easy_transilien/stop.rb', line 14 def station_name @station_name ||= ms_stop && ms_stop.stop_point.name end |
#stop_point_idx ⇒ Object
22 23 24 |
# File 'lib/easy_transilien/stop.rb', line 22 def stop_point_idx @stop_point_idx ||= ms_stop && ms_stop.stop_point.payload['StopPointIdx'] end |
#stop_time ⇒ Object
10 11 12 |
# File 'lib/easy_transilien/stop.rb', line 10 def stop_time @stop_time ||= ms_stop && ms_stop.stop_time end |
#time ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/easy_transilien/stop.rb', line 31 def time now = Time.new year = access_time && access_time.year || now.year month = access_time && access_time.month || now.month day = (access_time && access_time.day || now.day) this_month_days_count = Date.new(now.year, now.month, -1).day return Time.local(year + 1, 1, 1, stop_time.hour, stop_time.minute) if stop_time.day.to_i == 1 && month == 12 && day == this_month_days_count return Time.local(year, month + 1, 1, stop_time.hour, stop_time.minute) if stop_time.day.to_i == 1 && this_month_days_count == now.day Time.local(year, month, day, stop_time.hour, stop_time.minute) end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/easy_transilien/stop.rb', line 42 def to_s "#{station_name}#{"(#{name_at_stop})" if name_at_stop}@#{stop_time.day.to_i > 0 ? "(+#{stop_time.day.to_i})" : '' }#{'%02d' % stop_time.hour}:#{'%02d' % stop_time.minute}" end |