class Ellen::Weather::Client

Constants

CITIES

TODO parse this weather.livedoor.com/forecast/rss/primary_area.xml

LIVEDOOR_WEATHER_API_URL

Public Class Methods

new() click to toggle source
# File lib/ellen/weather/client.rb, line 15
def initialize
  @client = Faraday.new do |connection|
    connection.adapter :net_http
    connection.response :json
  end
end

Public Instance Methods

get(city_name) click to toggle source
# File lib/ellen/weather/client.rb, line 22
def get(city_name)
  return 'undefined city name' unless city_code = cities[city_name.to_sym]
  response = @client.get("#{url}?city=#{city_code}").body
  response['forecasts'][0]['telop']
end

Private Instance Methods

cities() click to toggle source
# File lib/ellen/weather/client.rb, line 34
def cities
  CITIES
end
url() click to toggle source
# File lib/ellen/weather/client.rb, line 30
def url
  LIVEDOOR_WEATHER_API_URL
end