yahoo_weatherman 0.8 → 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -186,35 +186,32 @@ module Weatherman
186
186
 
187
187
  def translate!(attributes)
188
188
  if i18n?
189
- translate_days! attributes
190
189
  translate_text! attributes
190
+ translate_days! attributes
191
191
  translate_locations! attributes
192
192
  end
193
193
  attributes
194
194
  end
195
195
 
196
196
  def translate_text!(attributes)
197
- if attributes['text']
198
- attributes['text'] = language_translations[attributes['code']]
199
- end
197
+ translate_attribute('text', attributes, language_translations, 'code')
200
198
  end
201
199
 
202
- def translate_locations!(attributes)
203
- locations_translations = language_translations['locations']
204
-
205
- %w(city country region).each do |key|
206
- next unless attributes.key? key
200
+ def translate_days!(attributes)
201
+ translate_attribute('day', attributes, language_translations['forecasts']['days'])
202
+ end
207
203
 
208
- if translated = locations_translations[attributes[key]]
209
- attributes[key] = translated
210
- end
204
+ def translate_locations!(attributes)
205
+ (%w[city country region] & attributes.keys).each do |key|
206
+ translate_attribute(key, attributes, language_translations['locations'])
211
207
  end
212
208
  end
213
209
 
214
- def translate_days!(attributes)
215
- if day = attributes['day']
216
- days_translations = language_translations['forecasts']['days']
217
- attributes['day'] = days_translations[day]
210
+ def translate_attribute(name, attributes, translations, change_by = nil)
211
+ translation_key = attributes[(change_by || name)]
212
+
213
+ if attributes[name] and translations[translation_key]
214
+ attributes[name] = translations[translation_key]
218
215
  end
219
216
  end
220
217
 
@@ -10,7 +10,7 @@ require 'yahoo_weatherman/response'
10
10
 
11
11
  module Weatherman
12
12
 
13
- VERSION = '0.8'
13
+ VERSION = '0.9'
14
14
 
15
15
  URI = 'http://weather.yahooapis.com/forecastrss'
16
16
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "yahoo_weatherman"
3
- gem.version = "0.8"
3
+ gem.version = "0.9"
4
4
  gem.authors = ["Dalto Curvelano Junior"]
5
5
  gem.description = "A ruby wrapper to the Yahoo! Weather feed with i18n support."
6
6
  gem.summary = "A ruby wrapper to the Yahoo! Weather feed with i18n support."
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 8
8
- version: "0.8"
7
+ - 9
8
+ version: "0.9"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Dalto Curvelano Junior
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-04-21 00:00:00 -03:00
16
+ date: 2010-04-28 00:00:00 -03:00
17
17
  default_executable:
18
18
  dependencies: []
19
19