Class: CLIRouter
- Inherits:
-
Object
- Object
- CLIRouter
- Defined in:
- lib/models/cli_router.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#weather_forecast ⇒ Object
readonly
Returns the value of attribute weather_forecast.
Instance Method Summary collapse
- #commands ⇒ Object
- #help ⇒ Object
-
#initialize(args) ⇒ CLIRouter
constructor
A new instance of CLIRouter.
Constructor Details
#initialize(args) ⇒ CLIRouter
Returns a new instance of CLIRouter.
5 6 7 8 |
# File 'lib/models/cli_router.rb', line 5 def initialize(args) @weather_forecast = Forecast.new(WeatherData.new) @args = args # in fact this is ARGV end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/models/cli_router.rb', line 3 def args @args end |
#weather_forecast ⇒ Object (readonly)
Returns the value of attribute weather_forecast.
3 4 5 |
# File 'lib/models/cli_router.rb', line 3 def weather_forecast @weather_forecast end |
Instance Method Details
#commands ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/models/cli_router.rb', line 15 def commands if args.length == 1 puts weather_forecast.send(self.args[0]) elsif args.length == 0 help end end |
#help ⇒ Object
10 11 12 13 |
# File 'lib/models/cli_router.rb', line 10 def help weather_forecast.today puts "if you'd like a different forecast try something like 'forecast tomorrow'" end |