class SyncSign::Node

Object that represents a SyncSign node. TODO: Split this up and add support for non-display nodes.

Attributes

battery[R]

@return [Integer] the current battery level of this node (0-100)

id[R]

@return [String] the Node ID of this node.

model[R]

@return [String] model of thid node.

name[R]

@return [String] the friendly name of this node.

signal[R]

@return [Integer] the current signal level of this node (0-100)

Public Class Methods

new(service: nil, id: nil, name: nil, online: nil, battery: nil, signal: nil, model: nil, hubid: nil) click to toggle source

Initialize a new Node object (normally only called from Hub#nodes or Service#nodes).

# File lib/syncsign/node.rb, line 19
def initialize(service: nil, id: nil, name: nil, online: nil, battery: nil, signal: nil, model: nil, hubid: nil)
  @service = service
  @id = id
  @name = name
  @online = online
  @battery = battery
  @signal = signal
  @model = model
  @hubid = hubid
end
parse(service: nil, nodeinfo: nil) click to toggle source

Parse a JSON description of a single node into a Node object. Normally only called from Hub#nodes or Service#nodes. @api private

# File lib/syncsign/node.rb, line 46
def self.parse(service: nil, nodeinfo: nil)
  node_class = Node
  case nodeinfo['type']
    when 'DISPLAY'
      node_class = Display
    # TODO: support sensors and any other node types
  end
  node_class.new(
    service: service,
    id: nodeinfo['nodeId'],
    name: nodeinfo['name'],
    online: nodeinfo['onlined'],
    battery: nodeinfo['batteryLevel'],
    signal: nodeinfo['signalLevel'],
    model: nodeinfo['model'],
    hubid: nodeinfo['thingName']
  )
end
parse_collection(service: nil, nodeinfo: nil) click to toggle source

Parse JSON array of nodes into a collection of Node objects. @param service [SyncSign::Service] Instance of the SyncSign Service class. @param nodeinfo [String] Information about a collection of nodes,

in JSON format.

@return [Array] Array of Node objects. @api private

# File lib/syncsign/node.rb, line 72
    def self.parse_collection(service: nil, nodeinfo: nil)
      nodes = []
      nodeinfo.each do |node|
        nodes.push Node::parse(service: service, nodeinfo: node)
      end
p nodes
      nodes
    end

Public Instance Methods

hub() click to toggle source

Return the hub that this node is associated with

# File lib/syncsign/node.rb, line 38
def hub
  Hub.new(service: @service, sn: @hubid)
end
is_online?() click to toggle source

Return true if the node was online during the last information gathering.

# File lib/syncsign/node.rb, line 32
def is_online?
  @online
end