Class: Utopia::Trenni::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/trenni.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuffer

Returns a new instance of Buffer.



10
11
12
# File 'lib/utopia/trenni.rb', line 10

def initialize
	@parts = []
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



14
15
16
# File 'lib/utopia/trenni.rb', line 14

def parts
  @parts
end

Instance Method Details

#codeObject



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