Class: PlayTone
- Inherits:
-
DirectCommand
- Object
- Telegram
- RespondableTelegram
- DirectCommand
- PlayTone
- Includes:
- MessageTranslator
- Defined in:
- lib/telegrams/commands/direct/play_tone.rb
Constant Summary
Constants included from MessageTranslator
MessageTranslator::FILENAME_MAX_LENGTH
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#frequency ⇒ Object
readonly
Returns the value of attribute frequency.
Attributes inherited from RespondableTelegram
Attributes inherited from Telegram
Instance Method Summary collapse
- #as_bytes ⇒ Object
-
#initialize(frequency_hz, duration_ms, require_response = true) ⇒ PlayTone
constructor
A new instance of PlayTone.
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(frequency_hz, duration_ms, require_response = true) ⇒ PlayTone
Returns a new instance of PlayTone.
9 10 11 12 13 14 15 |
# File 'lib/telegrams/commands/direct/play_tone.rb', line 9 def initialize(frequency_hz, duration_ms, require_response=true) super(require_response) @command = 0x03 validate_arguments(frequency_hz, duration_ms) @frequency = frequency_hz @duration = duration_ms end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
7 8 9 |
# File 'lib/telegrams/commands/direct/play_tone.rb', line 7 def duration @duration end |
#frequency ⇒ Object (readonly)
Returns the value of attribute frequency.
7 8 9 |
# File 'lib/telegrams/commands/direct/play_tone.rb', line 7 def frequency @frequency end |
Instance Method Details
#as_bytes ⇒ Object
17 18 19 |
# File 'lib/telegrams/commands/direct/play_tone.rb', line 17 def as_bytes super.concat(integer_as_uword_bytes(@frequency)).concat(integer_as_uword_bytes(@duration)) end |