Class: XRT::Statement::Block

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

Direct Known Subclasses

Tag

Instance Method Summary collapse

Methods inherited from XRT::Statement

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

Constructor Details

#initialize(content) ⇒ Block

Returns a new instance of Block.



157
158
159
160
161
# File 'lib/xrt/statement.rb', line 157

def initialize(content)
  @children = []

  self << Directive.new(content)
end

Instance Method Details

#<<(statement) ⇒ Object



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

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

#childrenObject



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

def children
  @children
end

#closed?Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/xrt/statement.rb', line 163

def closed?
  children.last.kind_of? End
end

#contentObject



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

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

#inspectObject



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

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