A Builder integrates a number of Modules containing text manipulation utilities and provides an alternative ‘accomulation’ interface.
Methods
Attributes
| [RW] | buffer | The builder output is accomulated in the buffer. |
Public Class methods
[ show source ]
# File lib/glue/builder.rb, line 15
15: def include_builder(*modules)
16: for mod in modules
17: include mod
18: for meth in mod.public_instance_methods
19: self.module_eval %{
20: alias_method :_mixin_#{meth}, :#{meth}
21: def #{meth}(*args)
22: @buffer << _mixin_#{meth}(*args)
23: return self
24: end
25: }
26: end
27: end
28: end
Provide the target where the builder output will be accomulated. The builder utilizes duck typing to make it compatible with any target responding to <<.
[ show source ]
# File lib/glue/builder.rb, line 37
37: def initialize(buffer = '', options = {})
38: @buffer = buffer
39: end
Public Instance methods
Alias for #text!
Alias for #text!
Emit a text string.
[ show source ]
# File lib/glue/builder.rb, line 43
43: def text!(str)
44: @buffer << str
45:
46: return self
47: end
[ show source ]
# File lib/glue/builder.rb, line 51
51: def to_s
52: @buffer.to_s
53: end