simple_weather 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/simple_weather.rb +16 -13
  2. metadata +1 -1
@@ -4,10 +4,12 @@ require 'net/http'
4
4
 
5
5
  # api key from wunderground: 7b1e71b12f5535c0
6
6
  module SimpleWeather
7
- class Weather
8
- @@conditions = {}
7
+ class Weather
8
+ def initialize
9
+ @@conditions = {}
10
+ end
9
11
 
10
- def self.processAllNodes(root, hash = {})
12
+ def processAllNodes(root, hash = {})
11
13
  if root == nil
12
14
  return
13
15
  end
@@ -15,19 +17,19 @@ module SimpleWeather
15
17
  processNodeAttr(root, hash)
16
18
  if root.children.length > 0
17
19
  root.children.each { |c|
18
- self.processAllNodes(c, hash[root.name])
20
+ processAllNodes(c, hash[root.name])
19
21
  }
20
22
  end
21
23
  end
22
24
 
23
- def self.processNodeAttr(node, hash = {})
25
+ def processNodeAttr(node, hash = {})
24
26
  hash[node.name]['attributes'] = {}
25
27
  node.attributes.each { |k, v|
26
28
  hash[node.name]['attributes']["#{k}"] = v.to_s
27
29
  }
28
30
  end
29
31
 
30
- def self.updateWeather(city = 'College Park')
32
+ def updateWeather(city = 'College Park')
31
33
  base_url = 'http://www.google.com/ig/api?weather='
32
34
  url = URI.escape(base_url << city)
33
35
 
@@ -50,31 +52,31 @@ module SimpleWeather
50
52
  return getData
51
53
  end
52
54
 
53
- def self.getImageUrl
55
+ def getImageUrl
54
56
  @@conditions['weather']['current_conditions']['icon']['attributes']['data']
55
57
  end
56
58
 
57
- def self.getCondition
59
+ def getCondition
58
60
  @@conditions['weather']['current_conditions']['condition']['attributes']['data']
59
61
  end
60
62
 
61
- def self.getTemp_f
63
+ def getTemp_f
62
64
  @@conditions['weather']['current_conditions']['temp_f']['attributes']['data']
63
65
  end
64
66
 
65
- def self.getTemp_c
67
+ def getTemp_c
66
68
  @@conditions['weather']['current_conditions']['temp_c']['attributes']['data']
67
69
  end
68
70
 
69
- def self.getHumidity
71
+ def getHumidity
70
72
  @@conditions['weather']['current_conditions']['humidity']['attributes']['data']
71
73
  end
72
74
 
73
- def self.getWindCondition
75
+ def getWindCondition
74
76
  @@conditions['weather']['current_conditions']['wind_condition']['attributes']['data']
75
77
  end
76
78
 
77
- def self.getData
79
+ def getData
78
80
  data = {}
79
81
  data['icon_url'] = getImageUrl
80
82
  data['conditon'] = getCondition
@@ -84,4 +86,5 @@ module SimpleWeather
84
86
  end
85
87
  end
86
88
  end
89
+
87
90
  # ActionView::Base.send(:include, SimpleWeather) if defined?(ActionView::Base)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_weather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: