Module: Adafruit::IO::Client::Blocks
- Included in:
- Adafruit::IO::Client
- Defined in:
- lib/adafruit/io/client/blocks.rb
Instance Method Summary collapse
-
#block(*args) ⇒ Object
Get a block specified by ID.
-
#blocks(*args) ⇒ Object
Get all blocks for a dashboard.
-
#create_block(*args) ⇒ Object
Create a block.
-
#delete_block(*args) ⇒ Object
Delete a block.
-
#update_block(*args) ⇒ Object
Update a block.
-
#valid_block_properties ⇒ Object
The list of every valid property name that can be stored by Adafruit IO.
-
#valid_block_visual_types ⇒ Object
The list of every valid block type that can be presented by Adafruit IO.
Instance Method Details
#block(*args) ⇒ Object
Get a block specified by ID
15 16 17 18 19 20 21 |
# File 'lib/adafruit/io/client/blocks.rb', line 15 def block(*args) username, arguments = extract_username(args) dashboard_key = require_argument(arguments, :dashboard_key) block_id = get_key_from_arguments(arguments) get api_url(username, 'dashboards', dashboard_key, 'blocks', block_id) end |
#blocks(*args) ⇒ Object
Get all blocks for a dashboard. Requires dashboard_key.
7 8 9 10 11 12 |
# File 'lib/adafruit/io/client/blocks.rb', line 7 def blocks(*args) username, arguments = extract_username(args) dashboard_key = require_argument(arguments, :dashboard_key) get api_url(username, 'dashboards', dashboard_key, 'blocks') end |
#create_block(*args) ⇒ Object
Create a block
24 25 26 27 28 29 30 |
# File 'lib/adafruit/io/client/blocks.rb', line 24 def create_block(*args) username, arguments = extract_username(args) dashboard_key = require_argument(arguments, :dashboard_key) block_attrs = valid_block_attrs(arguments) post api_url(username, 'dashboards', dashboard_key, 'blocks'), block_attrs end |
#delete_block(*args) ⇒ Object
Delete a block
33 34 35 36 37 38 39 |
# File 'lib/adafruit/io/client/blocks.rb', line 33 def delete_block(*args) username, arguments = extract_username(args) dashboard_key = require_argument(arguments, :dashboard_key) block_id = get_key_from_arguments(arguments) delete api_url(username, 'dashboards', dashboard_key, 'blocks', block_id) end |
#update_block(*args) ⇒ Object
Update a block
42 43 44 45 46 47 48 49 |
# File 'lib/adafruit/io/client/blocks.rb', line 42 def update_block(*args) username, arguments = extract_username(args) dashboard_key = require_argument(arguments, :dashboard_key) block_id = get_key_from_arguments(arguments) block_attrs = valid_block_attrs(arguments) put api_url(username, 'dashboards', dashboard_key, 'blocks', block_id), block_attrs end |
#valid_block_properties ⇒ Object
The list of every valid property name that can be stored by Adafruit IO.
Not every property applies to every block. Boolean values should be stored as the string “yes” or “no”.
55 56 57 58 59 60 61 62 63 |
# File 'lib/adafruit/io/client/blocks.rb', line 55 def valid_block_properties %w( text value release fontSize onText offText backgroundColor onColor offColor min max step label orientation handle minValue maxValue ringWidth label xAxisLabel yAxisLabel yAxisMin yAxisMax tile fontColor showName showTimestamp errors historyHours showNumbers showLocation ) end |
#valid_block_visual_types ⇒ Object
The list of every valid block type that can be presented by Adafruit IO.
66 67 68 69 70 71 |
# File 'lib/adafruit/io/client/blocks.rb', line 66 def valid_block_visual_types %w( toggle_button slider momentary_button gauge line_chart text color_picker map stream image remote_control ) end |