class Barr::Blocks::Temperature

Attributes

location[R]

Public Class Methods

new(opts = {}) click to toggle source
Calls superclass method Barr::Block::new
# File lib/barr/blocks/temperature.rb, line 11
def initialize(opts = {})
  super

  @location = opts[:location]
  @unit = opts[:unit] || 'C'
end

Public Instance Methods

update!() click to toggle source
# File lib/barr/blocks/temperature.rb, line 18
def update!
  action = "xdg-open weather.yahoo.com\/country\/state\/city-#{@location}\/"
  @output = "%{A:#{action}:}#{weather.condition.temp}°#{@unit} #{weather.condition.text}%{A}"
end

Private Instance Methods

weather() click to toggle source
# File lib/barr/blocks/temperature.rb, line 25
def weather
  Weather.lookup(@location, weather_units)
end
weather_units() click to toggle source
# File lib/barr/blocks/temperature.rb, line 29
def weather_units
  @unit == 'F' ? Weather::Units::FAHRENHEIT : Weather::Units::CELSIUS
end