Class: Sablon::HTMLConverter::Collection

Inherits:
Node
  • Object
show all
Defined in:
lib/sablon/html/ast.rb

Overview

A container for an array of AST nodes with convenience methods to work with the internal array as if it were a regular node

Direct Known Subclasses

List, Root

Constant Summary

Constants inherited from Node

Node::PROPERTIES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

convert_style_property, node_name, process_properties, style_conversion

Constructor Details

#initialize(nodes) ⇒ Collection

Returns a new instance of Collection.



102
103
104
105
106
# File 'lib/sablon/html/ast.rb', line 102

def initialize(nodes)
  @properties ||= nil
  @attributes ||= {}
  @nodes = nodes
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



101
102
103
# File 'lib/sablon/html/ast.rb', line 101

def nodes
  @nodes
end

Instance Method Details

#<<(node) ⇒ Object



123
124
125
# File 'lib/sablon/html/ast.rb', line 123

def <<(node)
  @nodes << node
end

#accept(visitor) ⇒ Object



108
109
110
111
112
113
# File 'lib/sablon/html/ast.rb', line 108

def accept(visitor)
  super
  @nodes.each do |node|
    node.accept(visitor)
  end
end

#inspectObject



119
120
121
# File 'lib/sablon/html/ast.rb', line 119

def inspect
  "[#{nodes.map(&:inspect).join(', ')}]"
end

#to_docxObject



115
116
117
# File 'lib/sablon/html/ast.rb', line 115

def to_docx
  nodes.map(&:to_docx).join
end