Class: PlaySoundFile

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

Attributes inherited from RespondableTelegram

#command

Attributes inherited from Telegram

#type

Instance Method Summary collapse

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

#max_size_in_bytes

Constructor Details

#initialize(sound_filename, loop_sound = false, require_response = true) ⇒ PlaySoundFile

Returns a new instance of PlaySoundFile.

Raises:

  • (ArgumentError)


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

#nameObject (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_bytesObject



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

Returns:

  • (Boolean)


18
19
20
# File 'lib/telegrams/commands/direct/play_sound_file.rb', line 18

def loop_sound?
  @loop_sound == true
end