weatherbug 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,6 +115,3 @@ module WeatherBug
115
115
  end
116
116
 
117
117
  end
118
-
119
- WeatherBug.partner_id = 'f0c313fe-fffe-4f5d-96dc-5a5d6ec9eb30'
120
- stations = WeatherBug::nearby_stations(:zip_code => '08005')
@@ -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 => :to_i
12
- register_transformer 'aws:hi', :name => :temp_high, :transform => :to_i
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 = value.send(options[:transform]) if options.has_key?(:transform)
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
@@ -1,6 +1,6 @@
1
1
  module WeatherBug
2
2
 
3
- VERSION = [0, 0, 5]
3
+ VERSION = [0, 0, 6]
4
4
 
5
5
  def self.version
6
6
  VERSION.join('.')
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
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: 2010-11-30 00:00:00 -05:00
18
+ date: 2011-01-03 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency