Class Request::SetEarsPosition
In: lib/violet/request.rb
Parent: Base::Event
Event Action AudioStream Choregraphy TtsMessage IdMessage SetEarsPosition EventCollection Enumerable Query GET_EARS_POSITION Base Request dot/f_8.png

SetEarsPosition events change your rabbit‘s ears positions. you can set left ear position, or right ear position, or both.

Examples

    SetEarsPosition.new :posleft => 12                 # => #<Request::SetEarsPosition:0x2ad0b2c79680 @h={:posleft=>12}>
    SetEarsPosition.new :posright => 1                 # => #<Request::SetEarsPosition:0x2ad0b2c70260 @h={:posright=>1}>
    SetEarsPosition.new :posright => 5, :posleft => 5  # => #<Request::SetEarsPosition:0x2ad0b2c5e330 @h={:posleft=>5, :posright=>5}>

Methods

new   to_url  

Constants

MIN_POS = 0
MAX_POS = 16

Public Class methods

take an hash in parameter, with :posright and/or :posleft keys. values should be between SetEarsPosition::MIN_POS and SetEarsPosition::MAX_POS.

[Source]

     # File lib/violet/request.rb, line 152
152:     def initialize h
153:       @h = h.dup
154:       raise ArgumentError.new('at least :posright or :posleft must be set')             unless @h[:posleft] or @h[:posright]
155:       raise ArgumentError.new(":posright must be between #{MIN_POS} and #{MAX_POS}")    if @h[:posright] and not @h[:posright].to_i.between?(MIN_POS,MAX_POS)
156:       raise ArgumentError.new(":posleft  must be between #{MIN_POS} and #{MAX_POS}")    if @h[:posleft ] and not @h[:posleft ].to_i.between?(MIN_POS,MAX_POS)
157:     end

Public Instance methods

[Source]

     # File lib/violet/request.rb, line 159
159:     def to_url
160:       url = Array.new
161:       url << "posleft=#{@h[:posleft].to_i}"   if @h[:posleft]
162:       url << "posright=#{@h[:posright].to_i}" if @h[:posright]
163:       url.sort
164:     end

[Validate]