Class: Sablon::HTMLConverter::NodeProperties

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

Overview

Manages the properties for an AST node, includes factory methods for easy use at calling sites.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tagname, properties, whitelist) ⇒ NodeProperties

Returns a new instance of NodeProperties.



28
29
30
31
# File 'lib/sablon/html/node_properties.rb', line 28

def initialize(tagname, properties, whitelist)
  @tagname = tagname
  filter_properties(properties, whitelist)
end

Instance Attribute Details

#transferred_propertiesObject (readonly)

Returns the value of attribute transferred_properties.



6
7
8
# File 'lib/sablon/html/node_properties.rb', line 6

def transferred_properties
  @transferred_properties
end

Class Method Details

.paragraph(properties) ⇒ Object



8
9
10
# File 'lib/sablon/html/node_properties.rb', line 8

def self.paragraph(properties)
  new('w:pPr', properties, Paragraph::PROPERTIES)
end

.run(properties) ⇒ Object



24
25
26
# File 'lib/sablon/html/node_properties.rb', line 24

def self.run(properties)
  new('w:rPr', properties, Run::PROPERTIES)
end

.table(properties) ⇒ Object



12
13
14
# File 'lib/sablon/html/node_properties.rb', line 12

def self.table(properties)
  new('w:tblPr', properties, Table::PROPERTIES)
end

.table_cell(properties) ⇒ Object



20
21
22
# File 'lib/sablon/html/node_properties.rb', line 20

def self.table_cell(properties)
  new('w:tcPr', properties, TableCell::PROPERTIES)
end

.table_row(properties) ⇒ Object



16
17
18
# File 'lib/sablon/html/node_properties.rb', line 16

def self.table_row(properties)
  new('w:trPr', properties, TableRow::PROPERTIES)
end

Instance Method Details

#[](key) ⇒ Object



37
38
39
# File 'lib/sablon/html/node_properties.rb', line 37

def [](key)
  @properties[key.to_sym]
end

#[]=(key, value) ⇒ Object



41
42
43
# File 'lib/sablon/html/node_properties.rb', line 41

def []=(key, value)
  @properties[key.to_sym] = value
end

#inspectObject



33
34
35
# File 'lib/sablon/html/node_properties.rb', line 33

def inspect
  @properties.map { |k, v| v ? "#{k}=#{v}" : k }.join(';')
end

#to_docxObject



45
46
47
# File 'lib/sablon/html/node_properties.rb', line 45

def to_docx
  "<#{@tagname}>#{properties_word_ml}</#{@tagname}>" unless @properties.empty?
end