class XBeeRuby::Address16
Constants
- BROADCAST
Public Class Methods
from_a(array)
click to toggle source
# File lib/xbee-ruby/address_16.rb, line 29 def self.from_a array if array.length == 2 && array.all? {|x| (0..255).cover? x } self.new *array else raise ArgumentError, "#{array} is not a valid 16-bit address array" end end
from_s(string)
click to toggle source
# File lib/xbee-ruby/address_16.rb, line 21 def self.from_s string if matcher = /^(\h\h)[^\h]*(\h\h)$/.match(string) self.new *(matcher[1..2].map &:hex) else raise ArgumentError, "#{string} is not a valid 16-bit address string" end end
new(msb, lsb)
click to toggle source
# File lib/xbee-ruby/address_16.rb, line 17 def initialize msb, lsb @address = [msb, lsb] end
Public Instance Methods
==(other)
click to toggle source
# File lib/xbee-ruby/address_16.rb, line 45 def == other to_a == other.to_a end
to_a()
click to toggle source
# File lib/xbee-ruby/address_16.rb, line 41 def to_a @address end
to_s()
click to toggle source
# File lib/xbee-ruby/address_16.rb, line 37 def to_s '%02x%02x' % @address end