Class: Zerbo::Packet
- Inherits:
-
Object
- Object
- Zerbo::Packet
- Defined in:
- lib/zerbo.rb
Direct Known Subclasses
BadSignal, Event, FrequencyBins, Impedence, SQI, SleepStage, SliceEnd, Version, Waveform, ZeoTimeStamp
Class Attribute Summary collapse
-
.id ⇒ Object
Returns the value of attribute id.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#sequence ⇒ Object
readonly
Returns the value of attribute sequence.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #guess_length ⇒ Object
-
#initialize(owner, time, subtime, sequence, data) ⇒ Packet
constructor
A new instance of Packet.
- #inspect ⇒ Object
- #name ⇒ Object (also: #to_s)
- #to_i ⇒ Object
Constructor Details
#initialize(owner, time, subtime, sequence, data) ⇒ Packet
Returns a new instance of Packet.
107 108 109 110 111 |
# File 'lib/zerbo.rb', line 107 def initialize(owner, time, subtime, sequence, data) @owner = owner @sequence = sequence @data = data end |
Class Attribute Details
.id ⇒ Object
Returns the value of attribute id.
98 99 100 |
# File 'lib/zerbo.rb', line 98 def id @id end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
101 102 103 |
# File 'lib/zerbo.rb', line 101 def data @data end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
101 102 103 |
# File 'lib/zerbo.rb', line 101 def owner @owner end |
#sequence ⇒ Object (readonly)
Returns the value of attribute sequence.
101 102 103 |
# File 'lib/zerbo.rb', line 101 def sequence @sequence end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
101 102 103 |
# File 'lib/zerbo.rb', line 101 def type @type end |
Class Method Details
.inherited(klass) ⇒ Object
93 94 95 |
# File 'lib/zerbo.rb', line 93 def self.inherited(klass) DATA_TYPE_CLASSES << klass end |
Instance Method Details
#guess_length ⇒ Object
113 114 115 |
# File 'lib/zerbo.rb', line 113 def guess_length data.index('A') end |
#inspect ⇒ Object
132 133 134 |
# File 'lib/zerbo.rb', line 132 def inspect format_inspect((to_i || data).inspect) end |
#name ⇒ Object Also known as: to_s
127 128 129 |
# File 'lib/zerbo.rb', line 127 def name self.class.name.split('::').last end |
#to_i ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/zerbo.rb', line 117 def to_i if data.length == 2 unpack('v').first elsif data.length == 4 unpack('V').first else raise NotImplementedError end end |