Class: Glaemscribe::API::IfTree::CodeBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/api/if_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_if_cond = nil) ⇒ CodeBlock

Returns a new instance of CodeBlock.



138
139
140
141
# File 'lib/api/if_tree.rb', line 138

def initialize(parent_if_cond = nil)
  @parent_if_cond = parent_if_cond
  @terms          = []
end

Instance Attribute Details

#parent_if_condObject

Returns the value of attribute parent_if_cond.



137
138
139
# File 'lib/api/if_tree.rb', line 137

def parent_if_cond
  @parent_if_cond
end

#termsObject

Returns the value of attribute terms.



137
138
139
# File 'lib/api/if_tree.rb', line 137

def terms
  @terms
end

Instance Method Details

#inspectObject



148
149
150
151
152
153
# File 'lib/api/if_tree.rb', line 148

def inspect
  ret = ""
  ret += "|-ROOT\n" if !parent_if_cond
  ret += "#{prefix} Code block\n" +
  @terms.map{|t| t.inspect}.join("\n")
end

#offsetObject



142
143
144
# File 'lib/api/if_tree.rb', line 142

def offset
  ((parent_if_cond)?(parent_if_cond.offset):("")) + " "
end

#prefixObject



145
146
147
# File 'lib/api/if_tree.rb', line 145

def prefix
  offset + "|- "
end