class XBee::Address64

Constants

BROADCAST
COORDINATOR

Public Class Methods

from_array(array) click to toggle source
# File lib/xbee/address_64.rb, line 21
def from_array(array)
        if array.length == 8 && array.all? { |x| (0..255).cover? x }
                new *array
        else
                raise ArgumentError, "#{array.inspect} is not a valid 64-bit address array"
        end
end
from_string(string) click to toggle source
# File lib/xbee/address_64.rb, line 12
def from_string(string)
        if (matcher = /^(\h\h)[^\h]*(\h\h)[^\h]*(\h\h)[^\h]*(\h\h)[^\h]*(\h\h)[^\h]*(\h\h)[^\h]*(\h\h)[^\h]*(\h\h)$/.match(string))
                new *(matcher[1..8].map &:hex)
        else
                raise ArgumentError, "#{string.inspect} is not a valid 64-bit address string"
        end
end
new(b1, b2, b3, b4, b5, b6, b7, b8) click to toggle source
# File lib/xbee/address_64.rb, line 6
def initialize(b1, b2, b3, b4, b5, b6, b7, b8)
        @bytes = [b1, b2, b3, b4, b5, b6, b7, b8]
end

Public Instance Methods

to_s() click to toggle source
# File lib/xbee/address_64.rb, line 32
def to_s
        ('%02x' * 8) % @bytes
end