Class: ElTiempoCLI
- Inherits:
-
Thor
- Object
- Thor
- ElTiempoCLI
- Defined in:
- lib/eltiempobcn.rb
Class Method Summary collapse
Instance Method Summary collapse
- #av_max(place_name) ⇒ Object
- #av_min(place_name) ⇒ Object
- #list ⇒ Object
- #today(place_name) ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
68 69 70 |
# File 'lib/eltiempobcn.rb', line 68 def self.exit_on_failure? true end |
.start(args) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/eltiempobcn.rb', line 56 def self.start( args ) if @@places clean_args = args clean_args[ 0 ] = args[ 0 ].sub( /^-*/, "" ) unless clean_args[ 0 ].nil? # remove the leading dashes before execuing the start method super( clean_args ) else puts "Couldn't connect with the server, please check your connection and try again later" end end |
Instance Method Details
#av_max(place_name) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/eltiempobcn.rb', line 25 def av_max( place_name ) place = Place.set_temperatures( place_name.to_s, @@places ) if place.kind_of?( Place ) puts "The average temperature for the Maximums this week in #{ place.name } are: #{ place.max_avg } celsius degrees" else puts "Couldn't find the city #{ place_name } or its data." end end |
#av_min(place_name) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/eltiempobcn.rb', line 37 def av_min( place_name ) place = Place.set_temperatures( place_name.to_s, @@places ) if place.kind_of?( Place ) puts "The average temperature for the minimuims this week in #{ place.name } are: #{ place.min_avg } celsius degrees" else puts "Couldn't find the city #{ place_name } or its data." end end |
#list ⇒ Object
49 50 51 |
# File 'lib/eltiempobcn.rb', line 49 def list puts @@places_names.join( " | " ) end |
#today(place_name) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/eltiempobcn.rb', line 13 def today( place_name ) place = Place.set_temperatures( place_name.to_s, @@places ) if place.kind_of?( Place ) puts "Today's temperatures for #{ place.name } are: [ min: #{ place.min_today }, max: #{ place.max_today } ] celsius" else puts "Couldn't find the city #{ place_name } or its data." end end |