Class: XRT::Statement::Block

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

Direct Known Subclasses

Tag, TagPair

Instance Method Summary collapse

Methods inherited from XRT::Statement

#==, #auto_indent, #contains_directive?, #depth, #find_block_texts, #find_blocks, #find_blocks_with_directive, #include?, #replace_child, #statements

Constructor Details

#initialize(content) ⇒ Block

Returns a new instance of Block.



165
166
167
168
169
# File 'lib/xrt/statement.rb', line 165

def initialize(content)
  @children = []

  self << Directive.new(content)
end

Instance Method Details

#<<(statement) ⇒ Object



175
176
177
178
# File 'lib/xrt/statement.rb', line 175

def << statement
  raise "trying to push_child to closed block: #{self.inspect} << #{statement.inspect}" if closed?
  @children << statement
end

#childrenObject



180
181
182
# File 'lib/xrt/statement.rb', line 180

def children
  @children
end

#closed?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/xrt/statement.rb', line 171

def closed?
  children.last.kind_of? End
end

#contentObject



184
185
186
# File 'lib/xrt/statement.rb', line 184

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

#inspectObject



188
189
190
# File 'lib/xrt/statement.rb', line 188

def inspect
  "(#{self.class}:#{self.children})"
end