Class: AmbientIot::Client
- Inherits:
-
Object
- Object
- AmbientIot::Client
- Defined in:
- lib/ambient_iot/client.rb
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #append_timestamp=(flag) ⇒ Object
- #append_timestamp? ⇒ Boolean
- #info ⇒ Object (also: #prop, #property)
-
#initialize(channel_id, options = {}) ⇒ Client
constructor
A new instance of Client.
- #read(options = {}) ⇒ Object
- #write ⇒ Object (also: #sync, #synchronize)
Constructor Details
#initialize(channel_id, options = {}) ⇒ Client
Returns a new instance of Client.
31 32 33 34 35 36 37 38 39 |
# File 'lib/ambient_iot/client.rb', line 31 def initialize channel_id, ={} @channel_id = channel_id @write_key = [:write_key] @read_key = [:read_key] @user_key = [:user_key] @post_data = [] @append_timestamp = true end |
Instance Method Details
#<<(data) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/ambient_iot/client.rb', line 41 def << data data = [data] unless data.is_a? Array if now = time_to_s Time.now data.each{|d| d["created"] = now} end @post_data += data end |
#append_timestamp=(flag) ⇒ Object
54 55 56 |
# File 'lib/ambient_iot/client.rb', line 54 def flag @append_timestamp = flag end |
#append_timestamp? ⇒ Boolean
50 51 52 |
# File 'lib/ambient_iot/client.rb', line 50 def @append_timestamp end |
#info ⇒ Object Also known as: prop, property
68 69 70 |
# File 'lib/ambient_iot/client.rb', line 68 def info get_property end |
#read(options = {}) ⇒ Object
64 65 66 |
# File 'lib/ambient_iot/client.rb', line 64 def read ={} get end |
#write ⇒ Object Also known as: sync, synchronize
58 59 60 |
# File 'lib/ambient_iot/client.rb', line 58 def write post end |