Class: XRT::Statement::Block

Inherits:
Directive show all
Defined in:
lib/xrt/statement.rb

Instance Method Summary collapse

Methods inherited from XRT::Statement

#==, #auto_indent, #depth, #find_block_texts, #find_blocks, #replace_child, #statements

Constructor Details

#initialize(content) ⇒ Block



133
134
135
136
# File 'lib/xrt/statement.rb', line 133

def initialize(content)
  super
  @children = []
end

Instance Method Details

#<<(statement) ⇒ Object



142
143
144
145
# File 'lib/xrt/statement.rb', line 142

def << statement
  raise 'trying to push_child to closed block' if closed?
  @children << statement
end

#childrenObject



147
148
149
# File 'lib/xrt/statement.rb', line 147

def children
  @children
end

#closed?Boolean



138
139
140
# File 'lib/xrt/statement.rb', line 138

def closed?
  children.last.kind_of? End
end

#contentObject



151
152
153
# File 'lib/xrt/statement.rb', line 151

def content
  @content + children.map{|c| c.content }.join
end

#inspectObject



155
156
157
# File 'lib/xrt/statement.rb', line 155

def inspect
  "<#{self.class}:#{@content},#{self.children}>"
end