Class: XRT::Statement::Block
Instance Method Summary
collapse
#==, #auto_indent, #contains_directive?, #depth, #find_block_texts, #find_blocks, #find_blocks_with_directive, #include?, #replace_child, #statements, #to_s
Constructor Details
#initialize(content) ⇒ Block
Returns a new instance of Block.
141
142
143
144
145
|
# File 'lib/xrt/statement.rb', line 141
def initialize(content)
@children = []
self << Directive.new(content)
end
|
Instance Method Details
#<<(statement) ⇒ Object
151
152
153
154
|
# File 'lib/xrt/statement.rb', line 151
def << statement
raise "trying to push_child to closed block: #{self.inspect} << #{statement.inspect}" if closed?
@children << statement
end
|
#children ⇒ Object
156
157
158
|
# File 'lib/xrt/statement.rb', line 156
def children
@children
end
|
#closed? ⇒ Boolean
147
148
149
|
# File 'lib/xrt/statement.rb', line 147
def closed?
children.last.kind_of? End
end
|
#content ⇒ Object
160
161
162
|
# File 'lib/xrt/statement.rb', line 160
def content
children.map{|c| c.content }.join
end
|
#inspect ⇒ Object
164
165
166
|
# File 'lib/xrt/statement.rb', line 164
def inspect
"(#{self.class}:#{self.children})"
end
|