Class: Undies::Output
- Inherits:
-
Object
- Object
- Undies::Output
- Defined in:
- lib/undies/output.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
the output class wraps an IO stream, gathers pretty printing options, and handles writing out buffered node stack items.
-
#pp ⇒ Object
readonly
the output class wraps an IO stream, gathers pretty printing options, and handles writing out buffered node stack items.
-
#pp_level ⇒ Object
Returns the value of attribute pp_level.
Instance Method Summary collapse
-
#initialize(io, opts = {}) ⇒ Output
constructor
A new instance of Output.
- #options=(opts) ⇒ Object
- #write(node, meth, level) ⇒ Object
Constructor Details
#initialize(io, opts = {}) ⇒ Output
10 11 12 13 |
# File 'lib/undies/output.rb', line 10 def initialize(io, opts={}) @io = io self. = opts end |
Instance Attribute Details
#io ⇒ Object (readonly)
the output class wraps an IO stream, gathers pretty printing options, and handles writing out buffered node stack items
7 8 9 |
# File 'lib/undies/output.rb', line 7 def io @io end |
#pp ⇒ Object (readonly)
the output class wraps an IO stream, gathers pretty printing options, and handles writing out buffered node stack items
7 8 9 |
# File 'lib/undies/output.rb', line 7 def pp @pp end |
#pp_level ⇒ Object
Returns the value of attribute pp_level.
8 9 10 |
# File 'lib/undies/output.rb', line 8 def pp_level @pp_level end |
Instance Method Details
#options=(opts) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/undies/output.rb', line 15 def (opts) if !opts.kind_of?(::Hash) raise ArgumentError, "please provide a hash to set options with" end # setup any pretty printing @pp = opts[:pp] || 0 @pp_level = opts[:pp_level] || 0 end |
#write(node, meth, level) ⇒ Object
25 26 27 28 |
# File 'lib/undies/output.rb', line 25 def write(node, meth, level) @io << node.class.prefix(node, meth, level+@pp_level, @pp) @io << node.class.send(meth, node) end |