Class: Sablon::HTMLConverter::NodeProperties
- Inherits:
-
Object
- Object
- Sablon::HTMLConverter::NodeProperties
- 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
-
#transferred_properties ⇒ Object
readonly
Returns the value of attribute transferred_properties.
Class Method Summary collapse
- .paragraph(properties) ⇒ Object
- .run(properties) ⇒ Object
- .table(properties) ⇒ Object
- .table_cell(properties) ⇒ Object
- .table_row(properties) ⇒ Object
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(tagname, properties, whitelist) ⇒ NodeProperties
constructor
A new instance of NodeProperties.
- #inspect ⇒ Object
- #to_docx ⇒ Object
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_properties ⇒ Object (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 |
#inspect ⇒ Object
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_docx ⇒ Object
45 46 47 |
# File 'lib/sablon/html/node_properties.rb', line 45 def to_docx "<#{@tagname}>#{properties_word_ml}</#{@tagname}>" unless @properties.empty? end |