Class: Barr::Blocks::Temperature
- Inherits:
-
Barr::Block
- Object
- Barr::Block
- Barr::Blocks::Temperature
- Defined in:
- lib/barr/blocks/temperature.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Attributes inherited from Barr::Block
#align, #bgcolor, #fgcolor, #icon, #interval, #output
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Temperature
constructor
A new instance of Temperature.
- #update! ⇒ Object
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
#location ⇒ Object (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 |