Class: Net::TTI::Capabilities
- Inherits:
-
Object
- Object
- Net::TTI::Capabilities
- Defined in:
- lib/net/tti/capabilities.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
-
#initialize(caps_bytes = []) ⇒ Capabilities
constructor
A new instance of Capabilities.
- #length ⇒ Object
- #to_binary_s ⇒ Object
-
#to_hexified_s ⇒ Object
Returns hexified bytes, delimited by spaces e.g.
Constructor Details
#initialize(caps_bytes = []) ⇒ Capabilities
Returns a new instance of Capabilities.
5 6 7 |
# File 'lib/net/tti/capabilities.rb', line 5 def initialize(caps_bytes=[]) @caps_bytes = caps_bytes end |
Class Method Details
.from_binary_string(string) ⇒ Object
13 14 15 |
# File 'lib/net/tti/capabilities.rb', line 13 def self.from_binary_string(string) Capabilities.new( string.unpack("C*") ) end |
.from_byte_array(bytes) ⇒ Object
9 10 11 |
# File 'lib/net/tti/capabilities.rb', line 9 def self.from_byte_array(bytes) Capabilities.new(bytes) end |
Instance Method Details
#[](index) ⇒ Object
17 18 19 |
# File 'lib/net/tti/capabilities.rb', line 17 def [](index) @caps_bytes[index] end |
#[]=(index, value) ⇒ Object
21 22 23 |
# File 'lib/net/tti/capabilities.rb', line 21 def []=(index, value) @caps_bytes[index] = value end |
#length ⇒ Object
25 26 27 |
# File 'lib/net/tti/capabilities.rb', line 25 def length @caps_bytes.length end |
#to_binary_s ⇒ Object
29 30 31 |
# File 'lib/net/tti/capabilities.rb', line 29 def to_binary_s @caps_bytes.pack("C*") end |
#to_hexified_s ⇒ Object
Returns hexified bytes, delimited by spaces e.g. [0x01,0x41,0x81,0xa1] -> “01 41 81 a1”
35 36 37 |
# File 'lib/net/tti/capabilities.rb', line 35 def to_hexified_s to_binary_s.scan(/../).join(" ") end |