Class: GroupingSyntaxTreeBuilder

Inherits:
SyntaxTreeBuilder show all
Defined in:
lib/rpdf2txt-rockit/syntax_tree.rb

Overview

A GroupingSyntaxTreeBuilder is a transform that alters the children values and then passes them on to the another STB that creates the tree. Needed for denormalization of grouped elements.

Instance Attribute Summary collapse

Attributes inherited from SyntaxTreeBuilder

#children_names, #inactive_children_indices, #node_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SyntaxTreeBuilder

#activate_child, #active_childrens, #inactivate_child, #inactive_childrens

Methods included from SourceCodeDumpable

as_code, as_method_named, as_module_method_named, #create_new, indent_lines, name_hash, #new_of_my_type, #parameter_named, #to_compact_src, #to_src_in_module, #type_to_src

Constructor Details

#initialize(startIndex, endIndex, syntaxTreeBuilder) ⇒ GroupingSyntaxTreeBuilder

Returns a new instance of GroupingSyntaxTreeBuilder.



277
278
279
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 277

def initialize(startIndex, endIndex, syntaxTreeBuilder)
  @range, @chained_builder = (startIndex..endIndex), syntaxTreeBuilder 
end

Instance Attribute Details

#chained_builderObject (readonly)

Returns the value of attribute chained_builder.



262
263
264
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 262

def chained_builder
  @chained_builder
end

#rangeObject (readonly)

Returns the value of attribute range.



262
263
264
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 262

def range
  @range
end

Class Method Details

.new(startIndex, endIndex, syntaxTreeBuilder) ⇒ Object



264
265
266
267
268
269
270
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 264

def GroupingSyntaxTreeBuilder.new(startIndex, endIndex, syntaxTreeBuilder)
  if startIndex == endIndex
    syntaxTreeBuilder
  else
    super(startIndex, endIndex, syntaxTreeBuilder)
  end
end

Instance Method Details

#==(other) ⇒ Object



286
287
288
289
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 286

def ==(other)
  other.class == self.class and
    other.range == range and other.chained_builder == chained_builder
end

#copyObject



272
273
274
275
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 272

def copy
  GroupingSyntaxTreeBuilder.new(@range.first, @range.last, 
		  @chained_builder.copy)
end

#create_tree(childrenValues) ⇒ Object



281
282
283
284
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 281

def create_tree(childrenValues)
  childrenValues[@range] = [childrenValues[@range]]
  @chained_builder.create_tree childrenValues
end

#to_src(name = nil, nameHash = {}) ⇒ Object



291
292
293
# File 'lib/rpdf2txt-rockit/syntax_tree.rb', line 291

def to_src(name = nil, nameHash = {})
  new_of_my_type(@range.first, @range.last, @chained_builder)
end