weatherbug 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/weatherbug.rb +0 -3
- data/lib/weatherbug/forecast.rb +2 -2
- data/lib/weatherbug/transformable_data.rb +15 -1
- data/lib/weatherbug/version.rb +1 -1
- metadata +4 -4
data/lib/weatherbug.rb
CHANGED
data/lib/weatherbug/forecast.rb
CHANGED
@@ -8,8 +8,8 @@ module WeatherBug
|
|
8
8
|
register_transformer 'aws:icon/@icon'
|
9
9
|
register_transformer 'aws:description'
|
10
10
|
register_transformer 'aws:prediction'
|
11
|
-
register_transformer 'aws:lo', :name => :temp_low, :transform => :
|
12
|
-
register_transformer 'aws:hi', :name => :temp_high, :transform => :
|
11
|
+
register_transformer 'aws:lo', :name => :temp_low, :transform => :nil_safe_to_i
|
12
|
+
register_transformer 'aws:hi', :name => :temp_high, :transform => :nil_safe_to_i
|
13
13
|
register_transformer 'aws:hi/@units', :name => :temp_units
|
14
14
|
register_transformer 'aws:prob-of-precip', :name => :probability_of_precipitation
|
15
15
|
|
@@ -19,13 +19,27 @@ module WeatherBug
|
|
19
19
|
# If this thing is empty, skip it
|
20
20
|
next if value.nil?
|
21
21
|
# If this thing needs to be transformed, transform it (from a string)
|
22
|
-
value =
|
22
|
+
value = TransformableData.send(options[:transform], value) if options.has_key?(:transform)
|
23
23
|
# Assign it on the class
|
24
24
|
object.send("#{options[:name]}=", value)
|
25
25
|
end
|
26
26
|
object
|
27
27
|
end
|
28
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def self.to_i(value)
|
32
|
+
value.to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.to_f(value)
|
36
|
+
value.to_f
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.nil_safe_to_i(value)
|
40
|
+
value == '--' ? nil : value.to_i
|
41
|
+
end
|
42
|
+
|
29
43
|
end
|
30
44
|
|
31
45
|
end
|
data/lib/weatherbug/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weatherbug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Crepezzi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-03 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|