Class: Utopia::Trenni::Buffer
- Inherits:
-
Object
- Object
- Utopia::Trenni::Buffer
- Defined in:
- lib/utopia/trenni.rb
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
Instance Method Summary collapse
- #code ⇒ Object
- #expression(text) ⇒ Object
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
- #output(text) ⇒ Object
- #text(text) ⇒ Object
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
10 11 12 |
# File 'lib/utopia/trenni.rb', line 10 def initialize @parts = [] end |
Instance Attribute Details
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
14 15 16 |
# File 'lib/utopia/trenni.rb', line 14 def parts @parts end |
Instance Method Details
#code ⇒ Object
30 31 32 33 34 |
# File 'lib/utopia/trenni.rb', line 30 def code parts = ['_out = [] ; '] + @parts + ['_out.join'] code = parts.join end |
#expression(text) ⇒ Object
22 23 24 |
# File 'lib/utopia/trenni.rb', line 22 def expression(text) @parts << "#{text} ; " end |
#output(text) ⇒ Object
26 27 28 |
# File 'lib/utopia/trenni.rb', line 26 def output(text) @parts << "_out << (#{text}) ; " end |
#text(text) ⇒ Object
16 17 18 19 20 |
# File 'lib/utopia/trenni.rb', line 16 def text(text) text = text.gsub('\\', '\\\\\\').gsub('@', '\\@') @parts << "_out << %q@#{text}@ ; " end |