Class: DCMetro::Cli::Application
- Inherits:
-
Thor
- Object
- Thor
- DCMetro::Cli::Application
- Defined in:
- lib/dcmetro/cli/application.rb
Instance Method Summary collapse
- #alerts ⇒ Object
- #line(color = nil) ⇒ Object
- #lines(color = nil) ⇒ Object
- #station(from, to = nil) ⇒ Object
Instance Method Details
#alerts ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dcmetro/cli/application.rb', line 13 def alerts # # $dcmetro alerts # => *** Alert! Alert! *** x = DCMetro::Information.new alerts = parse_json x.alerts display_alerts alerts end |
#line(color = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dcmetro/cli/application.rb', line 25 def line color=nil # # $dcmetro line # => Orange, Blue, Silver, Red, etc ... # # $dcmetro line Red # => Displays the stations on the Red Line x = DCMetro::Information.new if !color.nil? line = parse_json x.line(color) line["Stations"].each { |station| puts station['Name']} else lines = parse_json x.line lines["Lines"].each do |line| color = get_color(line['LineCode']) puts "#{color}#{line['DisplayName']}#{COLOR_OFF}" end end end |
#lines(color = nil) ⇒ Object
49 50 51 |
# File 'lib/dcmetro/cli/application.rb', line 49 def lines color=nil invoke :line end |
#station(from, to = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/dcmetro/cli/application.rb', line 55 def station(from, to=nil) # # $dcmetro station Greenbelt # => Displays the departure and arrival times at the Greenbelt Station # # $dcmetro station Greenbelt -a # => Displays the alerts, departure and arrival times at the Greenbelt Station # x = DCMetro::Information.new if [:alerts] y = parse_json x.alerts display_alerts y end if to.nil? x = parse_json x.station(from) train_time = x['Trains'].empty? ? "Sorry, there is no information for #{from}." : display_trains(x['Trains']) puts train_time if !train_time.kind_of?(Array) train_time else x = x.station(from,to) y = parse_json x display_travel_info y end end |