Class: Libastag::Rabbit

Inherits:
Object
  • Object
show all
Defined in:
lib/libastag.rb

Overview

this class store all attribute of a Nabaztag. it receive events and retrieve information from your user account or your #Rabbit (see public methods).

Constant Summary collapse

SERIAL_MATCHER =

used to check serial

/^[0-9A-F]+$/i
TOKEN_MATCHER =

used to check token

/^[0-9]+$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serial, token) ⇒ Rabbit

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.

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/libastag.rb', line 50

def initialize serial, token
  raise ArgumentError.new("bad serial : #{serial}") unless serial =~ SERIAL_MATCHER
  raise ArgumentError.new("bad token  : #{token }") unless token  =~  TOKEN_MATCHER
  @serial = serial.upcase
  @token  = token.to_i
#     _________                     _________
#    /         \                   /         \
 @right_ear,                    @left_ear          = RabbitEar.new(:right), RabbitEar.new(:left)
#   |           |                 |           |
#   |           |                 |           |
#   |           |                 |           |
#   |           |                 |           |
#   |           |                 |           |
#   |           |                 |           |
#   |           |                 |           |
#   |           |                 |           |
#   |           |_________________|           |
#   |           |                 |           |
#   |           |                 |           |
#   |                                         |
#   |                                         |
#   |         |                     |         |
#   |                                         |
#   |                  ___                    |
                 @top_led                           = RabbitLed.new(:top)
#   |                   |                     |
#   |                                         |
#   |                                         |
#   |                                         |
 @right_led,    @middle_led,     @left_led          = RabbitLed.new(:right), RabbitLed.new(:middle), RabbitLed.new(:left)
#   |                                         |
#   |                                         |
#   |                                         |
#   |                                         |
#   |                                         |
#   |                   |                     |
#  /                                           \
                @bottom_led                         = RabbitLed.new :bottom
# -----------------------------------------------
end

Instance Attribute Details

#bottom_ledObject (readonly)

object that handle bottom led, see #RabbitLed.



42
43
44
# File 'lib/libastag.rb', line 42

def bottom_led
  @bottom_led
end

#left_earObject (readonly)

object that handle left ear, see #RabbitEar.



30
31
32
# File 'lib/libastag.rb', line 30

def left_ear
  @left_ear
end

#left_ledObject (readonly)

object that handle left led, see #RabbitLed.



36
37
38
# File 'lib/libastag.rb', line 36

def left_led
  @left_led
end

#middle_ledObject (readonly)

object that handle middle led, see #RabbitLed.



38
39
40
# File 'lib/libastag.rb', line 38

def middle_led
  @middle_led
end

#right_earObject (readonly)

object that handle right ear, see #RabbitEar.



32
33
34
# File 'lib/libastag.rb', line 32

def right_ear
  @right_ear
end

#right_ledObject (readonly)

object that handle right led, see #RabbitLed.



40
41
42
# File 'lib/libastag.rb', line 40

def right_led
  @right_led
end

#serialObject (readonly)

Serial number of the Nabaztag that will receive events



24
25
26
# File 'lib/libastag.rb', line 24

def serial
  @serial
end

#tokenObject (readonly)

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



28
29
30
# File 'lib/libastag.rb', line 28

def token
  @token
end

#top_ledObject (readonly)

object that handle top led, see #RabbitLed.



34
35
36
# File 'lib/libastag.rb', line 34

def top_led
  @top_led
end

Instance Method Details

#asleep?Boolean

TODO

Returns:

  • (Boolean)


95
96
97
# File 'lib/libastag.rb', line 95

def asleep?
  # TODO
end

#awake?Boolean

TODO

Returns:

  • (Boolean)


101
102
103
# File 'lib/libastag.rb', line 101

def awake?
  # TODO
end

#nameObject



92
93
94
# File 'lib/libastag.rb', line 92

def name
  # TODO
end

#sleep!Object

TODO



98
99
100
# File 'lib/libastag.rb', line 98

def sleep!
  # TODO
end

#versionObject

TODO



107
108
109
# File 'lib/libastag.rb', line 107

def version
  # TODO
end

#wakeup!Object

TODO



104
105
106
# File 'lib/libastag.rb', line 104

def wakeup!
  # TODO
end