Class: Meteorologist
- Inherits:
-
Object
- Object
- Meteorologist
- Defined in:
- lib/meteorologist.rb
Instance Method Summary collapse
- #forecast ⇒ Object
-
#initialize(location, options = {}) ⇒ Meteorologist
constructor
A new instance of Meteorologist.
- #location_name ⇒ Object
- #moon ⇒ Object
Constructor Details
#initialize(location, options = {}) ⇒ Meteorologist
Returns a new instance of Meteorologist.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/meteorologist.rb', line 4 def initialize(location, = {}) validate_environment @location = location @forecaster_class = .fetch(:forecaster) { ::Forecaster } @navigator_class = .fetch(:navigator) { ::Navigator } @moon_info_class = .fetch(:moon_info) { ::MoonInfo } @forecast_time = .fetch(:forecast_time) { Time.now } @units = .fetch(:units) { 'si' } # or 'us' for Imperial units end |
Instance Method Details
#forecast ⇒ Object
15 16 17 |
# File 'lib/meteorologist.rb', line 15 def forecast @forecast ||= @forecaster_class.new(coordinates, units, forecast_time) end |
#location_name ⇒ Object
23 24 25 |
# File 'lib/meteorologist.rb', line 23 def location_name navigator.location_name end |
#moon ⇒ Object
19 20 21 |
# File 'lib/meteorologist.rb', line 19 def moon @moon ||= @moon_info_class.new(forecast.moon_phase) end |