Class: Nabaztag::Message
- Inherits:
-
Object
- Object
- Nabaztag::Message
- Defined in:
- lib/nabaztag/message.rb
Constant Summary collapse
- SERVICE_ENCODING =
'iso-8859-1'- API_URI =
'http://api.nabaztag.com/vl/FR/api.jsp?'- FIELDS =
[ :idmessage, :posright, :posleft, :idapp, :tts, :chor, :chortitle, :ears, :nabcast, :ttlive, :voice, :speed, :pitch, :action ]
- ACTIONS =
{ :preview => 1, :friend_list => 2, :list_messages => 3, :get_timezone => 4, :get_signature => 5, :get_blacklist => 6, :get_sleep_state => 7, :get_version => 8, :get_voices => 9, :get_name => 10, :get_languages => 11, :preview_message => 12, :sleep => 13, :wake => 14 }
Instance Method Summary collapse
- #action=(name) ⇒ Object
- #expect(identifier) ⇒ Object
-
#initialize(mac, token) ⇒ Message
constructor
A new instance of Message.
- #send ⇒ Object
Constructor Details
#initialize(mac, token) ⇒ Message
Returns a new instance of Message.
36 37 38 39 |
# File 'lib/nabaztag/message.rb', line 36 def initialize(mac, token) @mac, @token = mac, token @expected_identifiers = [] end |
Instance Method Details
#action=(name) ⇒ Object
50 51 52 |
# File 'lib/nabaztag/message.rb', line 50 def action=(name) @action = ACTIONS[name] or raise "unknown action #{name}" end |
#expect(identifier) ⇒ Object
46 47 48 |
# File 'lib/nabaztag/message.rb', line 46 def expect(identifier) @expected_identifiers << identifier end |
#send ⇒ Object
41 42 43 44 |
# File 'lib/nabaztag/message.rb', line 41 def send puts request_uri Response.new(open(request_uri){ |io| io.read }) end |