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 ⇒ Object
Out.
Constructor Details
#initialize(zipper, separators = Reader::Separators.empty) ⇒ Default
Returns a new instance of Default.
11 12 13 14 |
# File 'lib/stupidedi/writer/default.rb', line 11 def initialize(zipper, separators = Reader::Separators.empty) @zipper, @separators = zipper, separators end |
Instance Attribute Details
#separators ⇒ Reader::Separators (readonly)
9 10 11 |
# File 'lib/stupidedi/writer/default.rb', line 9 def separators @separators end |
Instance Method Details
#write ⇒ Object
Returns out.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stupidedi/writer/default.rb', line 18 def write common = @separators.characters & @zipper.node.characters = common.to_a.map(&:inspect).join(", ") if common.present? raise Exceptions::OutputError, "separators #{} occur as data" end out = "" recurse(@zipper.node, @separators, out) return out end |