Class: ChawkRemote::Addr
- Inherits:
-
Object
- Object
- ChawkRemote::Addr
- Includes:
- HTTParty
- Defined in:
- lib/chawk_remote.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#host ⇒ Object
Returns the value of attribute host.
-
#series_key ⇒ Object
Returns the value of attribute series_key.
Instance Method Summary collapse
- #add_points(points) ⇒ Object
- #clear ⇒ Object
- #decrement(count) ⇒ Object
- #increment(count) ⇒ Object
-
#initialize(host, series_key, client_id, api_key) ⇒ Addr
constructor
A new instance of Addr.
- #last(length) ⇒ Object
- #range(from, to) ⇒ Object
- #since(from) ⇒ Object
Constructor Details
#initialize(host, series_key, client_id, api_key) ⇒ Addr
Returns a new instance of Addr.
9 10 11 12 13 14 15 16 17 |
# File 'lib/chawk_remote.rb', line 9 def initialize(host, series_key, client_id, api_key) @host = host @client_id = client_id @api_key = api_key @series_key = series_key #puts "#{@host} - #{@client_id} - #{@api_key} #{series_key}" end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/chawk_remote.rb', line 7 def api_key @api_key end |
#client_id ⇒ Object
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/chawk_remote.rb', line 7 def client_id @client_id end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/chawk_remote.rb', line 7 def host @host end |
#series_key ⇒ Object
Returns the value of attribute series_key.
7 8 9 |
# File 'lib/chawk_remote.rb', line 7 def series_key @series_key end |
Instance Method Details
#add_points(points) ⇒ Object
23 24 25 26 27 |
# File 'lib/chawk_remote.rb', line 23 def add_points(points) r = HTTParty.post "#{@host}/api/v1/nodes/#{@series_key}/add_points", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""}, :body => {"payload" => "{\"data\":[#{points.join(',')}]}", :meta => "{\"source\":\"chawk_remote\"}"} end |
#clear ⇒ Object
19 20 21 |
# File 'lib/chawk_remote.rb', line 19 def clear r = HTTParty.put "#{@host}/api/v1/nodes/#{@series_key}/clear", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end |
#decrement(count) ⇒ Object
35 36 37 38 39 |
# File 'lib/chawk_remote.rb', line 35 def decrement(count) r = HTTParty.put "#{@host}/api/v1/nodes/#{@series_key}/decrement", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""}, :body => {"payload" => "{\"data\":#{count}}", :meta => "{\"source\":\"chawk_remote\"}"} end |
#increment(count) ⇒ Object
29 30 31 32 33 |
# File 'lib/chawk_remote.rb', line 29 def increment(count) r = HTTParty.put "#{@host}/api/v1/nodes/#{@series_key}/increment", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""}, :body => {"payload" => "{\"data\":#{count}}", :meta => "{\"source\":\"chawk_remote\"}"} end |
#last(length) ⇒ Object
41 42 43 44 |
# File 'lib/chawk_remote.rb', line 41 def last(length) r = HTTParty.get "#{@host}/api/v1/nodes/#{@series_key}/last", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end |
#range(from, to) ⇒ Object
46 47 48 49 |
# File 'lib/chawk_remote.rb', line 46 def range(from, to) r = HTTParty.get "#{@host}/api/v1/nodes/#{@series_key}/range?from=#{from}&to=#{to}", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end |
#since(from) ⇒ Object
51 52 53 54 |
# File 'lib/chawk_remote.rb', line 51 def since (from) r = HTTParty.get "#{@host}/api/v1/nodes/#{@series_key}/since?from=#{from}", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end |