Class: Barr::Blocks::Temperature

Inherits:
Barr::Block show all
Defined in:
lib/barr/blocks/temperature.rb

Instance Attribute Summary collapse

Attributes inherited from Barr::Block

#align, #bgcolor, #fgcolor, #icon, #interval, #output

Instance Method Summary collapse

Methods inherited from Barr::Block

#<<, #colors, #destroy, #destroy!, #draw, #reassign_deprecated_option, #update

Constructor Details

#initialize(opts = {}) ⇒ Temperature



11
12
13
14
15
16
# File 'lib/barr/blocks/temperature.rb', line 11

def initialize(opts = {})
  super

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



9
10
11
# File 'lib/barr/blocks/temperature.rb', line 9

def location
  @location
end

Instance Method Details

#update!Object



18
19
20
21
# 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