Class: XRT::Statement::Block

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

Direct Known Subclasses

ControlBlock, 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, #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

#childrenObject



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

def children
  @children
end

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  children.last.kind_of? End
end

#contentObject



160
161
162
# File 'lib/xrt/statement.rb', line 160

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

#inspectObject



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

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