Class | Libastag::Rabbit |
In: |
lib/libastag.rb
|
Parent: | Object |
this class store all attribute of a Nabaztag. it receive events and retrieve information from your user account or your Rabbit (see public methods).
SERIAL_MATCHER | = | /^[0-9A-F]+$/i | used to check serial | |
TOKEN_MATCHER | = | /^[0-9]+$/ | used to check token |
bottom_led | [R] | object that handle bottom led, see RabbitLed. |
left_ear | [R] | object that handle left ear, see RabbitEar. |
left_led | [R] | object that handle left led, see RabbitLed. |
middle_led | [R] | object that handle middle led, see RabbitLed. |
right_ear | [R] | object that handle right ear, see RabbitEar. |
right_led | [R] | object that handle right led, see RabbitLed. |
serial | [R] | Serial number of the Nabaztag that will receive events |
token | [R] | The token is a series of digits given when you activate the Nabaztag receiver. This extra identification limits the risks of spam, since, in order to send a message, you need to know both the serial number and the toke |
top_led | [R] | object that handle top led, see RabbitLed. |
create a new Rabbit with given serial and token. make a basic syntax check of serial and token (see SERIAL_MATCHER and TOKEN_MATCHER), but it doesn‘t mean that they are valid.
# File lib/libastag.rb, line 46 46: def initialize serial, token 47: raise ArgumentError.new("bad serial : #{serial}") unless serial =~ SERIAL_MATCHER 48: raise ArgumentError.new("bad token : #{token }") unless token =~ TOKEN_MATCHER 49: @serial = serial.upcase 50: @token = token.to_i 51: # _________ _________ 52: # / \ / @right_ear, @left_ear = RabbitEar.new(:right), RabbitEar.new(:left) 53: # | | | | 54: # | | | | 55: # | | | | 56: # | | | | 57: # | | | | 58: # | | | | 59: # | | | | 60: # | | | | 61: # | |_________________| | 62: # | | | | 63: # | | | | 64: # | | 65: # | | 66: # | | | | 67: # | | 68: # | ___ | 69: @top_led = RabbitLed.new(:top) 70: # | | | 71: # | | 72: # | | 73: # | | 74: @right_led, @middle_led, @left_led = RabbitLed.new(:right), RabbitLed.new(:middle), RabbitLed.new(:left) 75: # | | 76: # | | 77: # | | 78: # | | 79: # | | 80: # | | | 81: # / @bottom_led = RabbitLed.new :bottom 82: # ----------------------------------------------- 83: end