Class: DcmBuffer
- Inherits:
-
Object
- Object
- DcmBuffer
- Defined in:
- lib/ecu/interfaces/dcm/buffer.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#constructor ⇒ Object
readonly
Returns the value of attribute constructor.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
- #append!(line) ⇒ Object
- #finish!(line) ⇒ Object
- #header_seen! ⇒ Object
-
#initialize ⇒ DcmBuffer
constructor
A new instance of DcmBuffer.
- #reset! ⇒ Object
- #start!(constructor, buffer) ⇒ Object
Constructor Details
#initialize ⇒ DcmBuffer
Returns a new instance of DcmBuffer.
3 4 5 6 7 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 3 def initialize @constructor = nil @header = :pre @buffer = [] end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
2 3 4 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 2 def buffer @buffer end |
#constructor ⇒ Object (readonly)
Returns the value of attribute constructor.
2 3 4 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 2 def constructor @constructor end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
2 3 4 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 2 def header @header end |
Instance Method Details
#append!(line) ⇒ Object
34 35 36 37 38 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 34 def append!(line) fail "No label started" if constructor.nil? @buffer << line end |
#finish!(line) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 18 def finish!(line) fail "Unexpected END" if constructor.nil? append!(line) constructor.from_dcm(buffer).tap { reset! } end |
#header_seen! ⇒ Object
30 31 32 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 30 def header_seen! @header = :after end |
#reset! ⇒ Object
25 26 27 28 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 25 def reset! @constructor = nil @buffer = [] end |
#start!(constructor, buffer) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ecu/interfaces/dcm/buffer.rb', line 9 def start!(constructor, buffer) fail "Nested parameter" unless self.buffer.empty? fail "Missing DCM header" if self.header == :pre @header = :done @constructor = constructor @buffer = buffer end |