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.



28
29
30
# File 'lib/utopia/trenni.rb', line 28

def initialize
	@parts = []
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



32
33
34
# File 'lib/utopia/trenni.rb', line 32

def parts
  @parts
end

Instance Method Details

#codeObject



48
49
50
51
52
# File 'lib/utopia/trenni.rb', line 48

def code
	parts = ["#{OUT} = [] ; "] + @parts + ["#{OUT}.join"]

	code = parts.join
end

#expression(text) ⇒ Object



40
41
42
# File 'lib/utopia/trenni.rb', line 40

def expression(text)
	@parts << "#{text} ; "
end

#output(text) ⇒ Object



44
45
46
# File 'lib/utopia/trenni.rb', line 44

def output(text)
	@parts << "#{OUT} << (#{text}) ; "
end

#text(text) ⇒ Object



34
35
36
37
38
# File 'lib/utopia/trenni.rb', line 34

def text(text)
	text = text.gsub('\\', '\\\\\\').gsub('@', '\\@')

	@parts << "#{OUT} << %q@#{text}@ ; "
end