Class: HumureClient
- Inherits:
-
Object
- Object
- HumureClient
- Defined in:
- lib/humure-client.rb,
lib/humure-client/api.rb,
lib/humure-client/client.rb,
lib/humure-client/version.rb
Constant Summary collapse
- VERSION =
"0.4.0"
Instance Attribute Summary collapse
-
#sensor ⇒ Object
Returns the value of attribute sensor.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #change_lamp_color(red, green, blue) ⇒ Object
- #humidity ⇒ Object
-
#initialize(options = {}) ⇒ HumureClient
constructor
Initialize a new humure client.
- #lamp ⇒ Object
- #switch_lamp_off ⇒ Object
- #switch_lamp_on ⇒ Object
- #temperature ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HumureClient
Initialize a new humure client
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/humure-client/client.rb', line 9 def initialize(={}) .each do |key, value| instance_variable_set("@#{key}", value) end raise ArgumentError.new("Option :token missing") if token.nil? @url ||= "http://localhost:3000" @sensor ||= "fake" end |
Instance Attribute Details
#sensor ⇒ Object
Returns the value of attribute sensor.
3 4 5 |
# File 'lib/humure-client/client.rb', line 3 def sensor @sensor end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/humure-client/client.rb', line 3 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/humure-client/client.rb', line 3 def url @url end |
Instance Method Details
#change_lamp_color(red, green, blue) ⇒ Object
26 27 28 |
# File 'lib/humure-client/api.rb', line 26 def change_lamp_color(red, green, blue) put_request("lamp/color/#{red}/#{green}/#{blue}") end |
#humidity ⇒ Object
6 7 8 |
# File 'lib/humure-client/api.rb', line 6 def humidity get_request("humidity") end |
#lamp ⇒ Object
14 15 16 |
# File 'lib/humure-client/api.rb', line 14 def lamp get_request("lamp") end |
#switch_lamp_off ⇒ Object
22 23 24 |
# File 'lib/humure-client/api.rb', line 22 def switch_lamp_off put_request("lamp/off") end |
#switch_lamp_on ⇒ Object
18 19 20 |
# File 'lib/humure-client/api.rb', line 18 def switch_lamp_on put_request("lamp/on") end |
#temperature ⇒ Object
10 11 12 |
# File 'lib/humure-client/api.rb', line 10 def temperature get_request("temperature") end |