Class: NoaaWeatherClient::CLI
- Inherits:
-
Object
- Object
- NoaaWeatherClient::CLI
- Defined in:
- lib/noaa_weather_client/cli.rb
Defined Under Namespace
Classes: Coordinate
Instance Attribute Summary collapse
-
#buffer ⇒ Object
writeonly
Sets the attribute buffer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(latitude, longitude) ⇒ CLI
constructor
A new instance of CLI.
- #render(*features) ⇒ Object
Constructor Details
#initialize(latitude, longitude) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 |
# File 'lib/noaa_weather_client/cli.rb', line 13 def initialize(latitude, longitude) @coordinate = Coordinate.new(latitude, longitude) raise ArgumentError, "Invalid coordinate #{latitude}, #{longitude}" unless coordinate.valid? end |
Instance Attribute Details
#buffer=(value) ⇒ Object
Sets the attribute buffer
11 12 13 |
# File 'lib/noaa_weather_client/cli.rb', line 11 def buffer=(value) @buffer = value end |
Class Method Details
.postal_code_to_coordinate(postal_code, buffer = STDOUT) ⇒ Object
5 6 7 8 9 |
# File 'lib/noaa_weather_client/cli.rb', line 5 def self.postal_code_to_coordinate(postal_code, buffer = STDOUT) client = NoaaWeatherClient.build_client coordinate = client.postal_code_to_coordinate postal_code buffer.puts Templates::PostalCode.new(coordinate).to_s end |
Instance Method Details
#render(*features) ⇒ Object
18 19 20 |
# File 'lib/noaa_weather_client/cli.rb', line 18 def render(*features) features.each { |f| render_feature buffer, f } end |