simple_weather 0.0.1 → 0.0.2

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 +33 -7
  2. metadata +1 -1
@@ -4,12 +4,37 @@ require 'net/http'
4
4
 
5
5
  # api key from wunderground: 7b1e71b12f5535c0
6
6
  module SimpleWeather
7
- class Weather
7
+ class << self
8
+ attr_accessor :configuration
9
+ end
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield(configuration)
17
+ end
18
+
19
+ class Configuration
20
+ attr_accessor :last_update, :conditions
21
+
8
22
  def initialize
9
23
  @last_update = Time.now
10
24
  @conditions = {}
11
25
  end
12
-
26
+ end
27
+
28
+ def self.included(base)
29
+ SimpleWeather.configure { |c| nil }
30
+ base.extend ClassMethods
31
+ base.send :include, InstanceMethods
32
+ end
33
+
34
+ module ClassMethods
35
+ end
36
+
37
+ module InstanceMethods
13
38
  def updateWeather(city = 'MD/College Park')
14
39
  base_url = 'http://api.wunderground.com/api/'
15
40
  api_key = '7b1e71b12f5535c0'
@@ -27,25 +52,26 @@ module SimpleWeather
27
52
  end
28
53
  end
29
54
 
30
- def getImageUrl()
55
+ def getImageUrl
31
56
  @conditions['current_observation']['icon_url']
32
57
  end
33
58
 
34
- def getWeather()
59
+ def getWeather
35
60
  @conditions['current_observation']['weather']
36
61
  end
37
62
 
38
- def getTemp_f()
63
+ def getTemp_f
39
64
  @conditions['current_observation']['temp_f']
40
65
  end
41
66
 
42
- def getTemp_c()
67
+ def getTemp_c
43
68
  @conditions['current_observation']['temp_c']
44
69
  end
45
70
 
46
- def getFeelsLike()
71
+ def getFeelsLike
47
72
  @conditions['current_observation']['fellslike_string']
48
73
  end
49
74
  end
50
75
  end
76
+
51
77
  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.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: