module Adafruit::IO::Client::Blocks
Public Instance Methods
block(*args)
click to toggle source
Get a block specified by ID
# 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)
click to toggle source
Get all blocks for a dashboard. Requires dashboard_key.
# 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)
click to toggle source
Create a block
# 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)
click to toggle source
Delete a block
# 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)
click to toggle source
Update a block
# 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()
click to toggle source
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”.
# 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()
click to toggle source
Private Instance Methods
valid_block_attrs(arguments)
click to toggle source
# File lib/adafruit/io/client/blocks.rb, line 75 def valid_block_attrs(arguments) get_query_from_arguments( arguments, %w(name properties visual_type column row size_x size_y block_feeds) ) end