Class: Postsvg::Translation::RecordEmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/postsvg/translation/record_emitter.rb

Overview

Accumulator of Model::Operator instances that the PsRenderer builds. Thin wrapper around an array; provides a uniform emit surface so handlers don't all need to know how the program is stored.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecordEmitter

Returns a new instance of RecordEmitter.



12
13
14
# File 'lib/postsvg/translation/record_emitter.rb', line 12

def initialize
  @records = []
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



10
11
12
# File 'lib/postsvg/translation/record_emitter.rb', line 10

def records
  @records
end

Instance Method Details

#emit(record) ⇒ Object



16
17
18
19
# File 'lib/postsvg/translation/record_emitter.rb', line 16

def emit(record)
  @records << record
  self
end

#emit_many(records) ⇒ Object



21
22
23
24
# File 'lib/postsvg/translation/record_emitter.rb', line 21

def emit_many(records)
  records.each { |r| emit(r) }
  self
end

#lengthObject



26
27
28
# File 'lib/postsvg/translation/record_emitter.rb', line 26

def length
  @records.length
end

#to_aObject



30
31
32
# File 'lib/postsvg/translation/record_emitter.rb', line 30

def to_a
  @records.dup
end