Class: Emfrp::CodegenContext::Block
- Inherits:
-
Object
- Object
- Emfrp::CodegenContext::Block
- Defined in:
- lib/emfrp/compile/c/codegen_context.rb
Constant Summary collapse
- T =
(0..20).map{|i| " " * i}
Instance Method Summary collapse
-
#initialize(head_str, elements, foot_str) ⇒ Block
constructor
A new instance of Block.
- #to_s(t = 0) ⇒ Object
Constructor Details
#initialize(head_str, elements, foot_str) ⇒ Block
Returns a new instance of Block.
197 198 199 200 201 |
# File 'lib/emfrp/compile/c/codegen_context.rb', line 197 def initialize(head_str, elements, foot_str) @head_str = head_str @elements = elements @foot_str = foot_str end |
Instance Method Details
#to_s(t = 0) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/emfrp/compile/c/codegen_context.rb', line 203 def to_s(t=0) res = "" res << T[t] + @head_str + "\n" @elements.each do |e| case e when Block res << e.to_s(t+1) + "\n" when String res << T[t+1] + e + "\n" end end res << T[t] + @foot_str end |