Class: Nabaztag::Message

Inherits:
Object
  • Object
show all
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

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

#sendObject



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