Class: Request::IdMessage
- Inherits:
-
Base::Event
- Object
- Base::Event
- Request::IdMessage
- Defined in:
- lib/violet/request.rb
Overview
IdMessage events are used with a message id from Library or a personal MP3 file. Library can be seen here : my.nabaztag.com/vl/action/myMessagesBiblio.do
Example (Batman)
IdMessage.new :idmessage => 10282 # => #<Request::IdMessage:0x2b28ec730128 @h={:idmessage=>10282}>
Constant Summary collapse
- MIN_IDMESSAGE =
1
Instance Method Summary collapse
-
#initialize(h) ⇒ IdMessage
constructor
take an Hash in parameter, with at least
:idmessage
key. - #to_url ⇒ Object
Methods inherited from Base::Event
Constructor Details
#initialize(h) ⇒ IdMessage
take an Hash in parameter, with at least :idmessage
key. the :idmessage
must respond_to to_i and have a to_i representation greater or equal than IdMessage::MIN_IDMESSAGE.
223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/violet/request.rb', line 223 def initialize h @h = h.dup raise ArgumentError.new('no :idmessage given') unless @h[:idmessage] raise ArgumentError.new(":idmessage must be greater than #{MIN_IDMESSAGE}") unless @h[:idmessage].to_i >= MIN_IDMESSAGE @h[:idmessage] = @h[:idmessage].to_i @h[:nabcasttitle] = URI.escape @h[:nabcasttitle] if @h[:nabcasttitle] @h[:nabcast] = @h[:nabcast].to_i if @h[:nabcast] end |
Instance Method Details
#to_url ⇒ Object
235 236 237 238 239 240 241 |
# File 'lib/violet/request.rb', line 235 def to_url url = Array.new @h.each_pair do |key,val| url << "#{key}=#{val}" if val end url end |