Class: Grubber::Config
- Inherits:
-
Object
- Object
- Grubber::Config
- Defined in:
- lib/grubber/config.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#store ⇒ Object
Returns the value of attribute store.
Class Method Summary collapse
Instance Method Summary collapse
- #coordinates ⇒ Object
- #has_auth? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(opts = {}) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/grubber/config.rb', line 8 def initialize(opts={}) @store = Grubber::Store.load[:grubber] location = store[:location] @lat = location[:lat] @lng = location[:lng] @credentials = store[:credentials] self end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
6 7 8 |
# File 'lib/grubber/config.rb', line 6 def credentials @credentials end |
#lat ⇒ Object
Returns the value of attribute lat.
6 7 8 |
# File 'lib/grubber/config.rb', line 6 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng.
6 7 8 |
# File 'lib/grubber/config.rb', line 6 def lng @lng end |
#store ⇒ Object
Returns the value of attribute store.
6 7 8 |
# File 'lib/grubber/config.rb', line 6 def store @store end |
Class Method Details
.load ⇒ Object
19 20 21 |
# File 'lib/grubber/config.rb', line 19 def self.load new end |
.update_auth(ckey, csec, tkey, tsec) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/grubber/config.rb', line 43 def self.update_auth(ckey, csec, tkey, tsec) [ckey, csec, tkey, tsec].each do |k| return nil if k.nil? || k == '' end Grubber::Store.update({ credentials: { consumer_key: ckey, consumer_secret: csec, token_key: tkey, token_secret: tsec } }) end |
Instance Method Details
#coordinates ⇒ Object
23 24 25 |
# File 'lib/grubber/config.rb', line 23 def coordinates [lat, lng] end |
#has_auth? ⇒ Boolean
27 28 29 |
# File 'lib/grubber/config.rb', line 27 def has_auth? !self.credentials.nil? end |