Class: ODFReport::Field
- Inherits:
-
Object
- Object
- ODFReport::Field
- Defined in:
- lib/odf-report/field.rb
Constant Summary collapse
- DELIMITERS =
%w([ ])
Instance Method Summary collapse
-
#initialize(opts, &block) ⇒ Field
constructor
A new instance of Field.
- #replace!(content, data_item = nil) ⇒ Object
- #set_source(record) ⇒ Object
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 if txt.gsub!(to_placeholder, sanitize(@data_source.value)) content.inner_html = txt end 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 |