Class: PureDocx::XmlGenerators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/puredocx/xml_generators/base.rb

Direct Known Subclasses

Cell, Image, Row, Table, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, rels_constructor) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/puredocx/xml_generators/base.rb', line 6

def initialize(content, rels_constructor)
  @content          = content
  @rels_constructor = rels_constructor
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/puredocx/xml_generators/base.rb', line 4

def content
  @content
end

#rels_constructorObject (readonly)

Returns the value of attribute rels_constructor.



4
5
6
# File 'lib/puredocx/xml_generators/base.rb', line 4

def rels_constructor
  @rels_constructor
end

Instance Method Details

#paramsObject



19
20
21
# File 'lib/puredocx/xml_generators/base.rb', line 19

def params
  {}
end

#templateObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/puredocx/xml_generators/base.rb', line 15

def template
  raise NotImplementedError, "#{__method__} is not implemented."
end

#xmlObject



11
12
13
# File 'lib/puredocx/xml_generators/base.rb', line 11

def xml
  params.each_with_object(template.clone) { |(param, value), memo| memo.gsub!(param, value.to_s) }
end