Class: ODFReport::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/odf-report/field.rb

Direct Known Subclasses

Image, Text

Constant Summary collapse

DELIMITERS =
%w([ ])

Instance Method Summary collapse

Constructor Details

#initialize(opts, &block) ⇒ Field

Returns a new instance of Field.



6
7
8
9
# File 'lib/odf-report/field.rb', line 6

def initialize(opts, &block)
  @name = opts[:name]
  @data_source = DataSource.new(opts, &block)
end

Instance Method Details

#replace!(content, data_item = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/odf-report/field.rb', line 16

def replace!(content, data_item = nil)

  txt = content.inner_html

  txt.gsub!(to_placeholder, sanitize(@data_source.value))

  content.inner_html = txt

end

#set_source(record) ⇒ Object



11
12
13
14
# File 'lib/odf-report/field.rb', line 11

def set_source(record)
  @data_source.set_source(record)
  self
end