Class: PlaySoundFile
- Inherits:
-
DirectCommand
- Object
- Telegram
- RespondableTelegram
- DirectCommand
- PlaySoundFile
- Includes:
- MessageTranslator
- Defined in:
- lib/telegrams/commands/direct/play_sound_file.rb
Constant Summary
Constants included from MessageTranslator
MessageTranslator::FILENAME_MAX_LENGTH
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from RespondableTelegram
Attributes inherited from Telegram
Instance Method Summary collapse
- #as_bytes ⇒ Object
-
#initialize(sound_filename, loop_sound = false, require_response = true) ⇒ PlaySoundFile
constructor
A new instance of PlaySoundFile.
- #loop_sound? ⇒ Boolean
Methods included from MessageTranslator
#add_default_extension_if_missing, #boolean_as_bytes, #boolean_from_bytes, #integer_as_bytes, #integer_as_ulong_bytes, #integer_as_uword_bytes, #integer_from_bytes, #string_as_bytes, #string_from_bytes
Methods inherited from RespondableTelegram
#require_response=, #require_response?
Methods inherited from Telegram
Constructor Details
#initialize(sound_filename, loop_sound = false, require_response = true) ⇒ PlaySoundFile
Returns a new instance of PlaySoundFile.
9 10 11 12 13 14 15 16 |
# File 'lib/telegrams/commands/direct/play_sound_file.rb', line 9 def initialize(sound_filename, loop_sound=false, require_response=true) raise ArgumentError, "sound_filename is required" if sound_filename.nil? super(require_response) @command = 0x02 # playsoundfile @name = adjust_sound_filename(sound_filename) @loop_sound = loop_sound end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/telegrams/commands/direct/play_sound_file.rb', line 7 def name @name end |
Instance Method Details
#as_bytes ⇒ Object
22 23 24 |
# File 'lib/telegrams/commands/direct/play_sound_file.rb', line 22 def as_bytes bytes = super.concat(loop_sound_as_bytes).concat(filename_as_bytes) end |
#loop_sound? ⇒ Boolean
18 19 20 |
# File 'lib/telegrams/commands/direct/play_sound_file.rb', line 18 def loop_sound? @loop_sound == true end |