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_blocks, #replace_child

Constructor Details

#initialize(content) ⇒ Block

Returns a new instance of Block.



118
119
120
121
# File 'lib/xrt/statement.rb', line 118

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

Instance Method Details

#<<(statement) ⇒ Object



127
128
129
130
# File 'lib/xrt/statement.rb', line 127

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

#childrenObject



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

def children
  @children
end

#closed?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/xrt/statement.rb', line 123

def closed?
  children.last.kind_of? End
end

#contentObject



136
137
138
# File 'lib/xrt/statement.rb', line 136

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

#inspectObject



140
141
142
# File 'lib/xrt/statement.rb', line 140

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