Class: Stupidedi::Writer::Default
- Inherits:
-
Object
- Object
- Stupidedi::Writer::Default
- Defined in:
- lib/stupidedi/writer/default.rb
Instance Attribute Summary collapse
- #separators ⇒ Reader::Separators readonly
Instance Method Summary collapse
-
#initialize(zipper, separators = Reader::Separators.empty) ⇒ Default
constructor
A new instance of Default.
-
#write(out = "")
Out.
Constructor Details
#initialize(zipper, separators = Reader::Separators.empty) ⇒ Default
Returns a new instance of Default.
9 10 11 12 |
# File 'lib/stupidedi/writer/default.rb', line 9 def initialize(zipper, separators = Reader::Separators.empty) @zipper, @separators = zipper, separators end |
Instance Attribute Details
#separators ⇒ Reader::Separators (readonly)
7 8 9 |
# File 'lib/stupidedi/writer/default.rb', line 7 def separators @separators end |
Instance Method Details
#write(out = "")
Returns out.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stupidedi/writer/default.rb', line 15 def write(out = "") unless @zipper.node.transmission? or @zipper.node.interchange? common = @separators.characters & @zipper.node.characters = common.to_a.map(&:inspect).join(", ") if common.present? raise Exceptions::OutputError, "separator characters #{} occur as data" end end out.tap { recurse(@zipper.node, @separators, out) } end |