Class: 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 = "") ⇒ Object
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 = "") ⇒ Object
Returns out.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stupidedi/writer/default.rb', line 16 def write(out = "") common = @separators.characters & @zipper.node.characters = common.to_a.map(&:inspect).join(", ") if common.present? raise Exceptions::OutputError, "separators #{} occur as data" end recurse(@zipper.node, @separators, out) return out end |