Class: NoaaWeatherClient::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/noaa_weather_client/cli.rb

Defined Under Namespace

Classes: Coordinate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude, longitude) ⇒ CLI

Returns a new instance of CLI.

Raises:

  • (ArgumentError)


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

Parameters:

  • value

    the value to set the attribute buffer to.



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