Class: Thinreports::BasicReport::Core::Shape::TextBlock::Formatter::Basic

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb

Direct Known Subclasses

Datetime, Number, Padding

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#blank_value?, #call_block_in, #deep_copy, included

Constructor Details

#initialize(format) ⇒ Basic

Returns a new instance of Basic.



14
15
16
# File 'lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb', line 14

def initialize(format)
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



12
13
14
# File 'lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb', line 12

def format
  @format
end

Instance Method Details

#apply(value) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb', line 18

def apply(value)
  value = apply_format_to(value) if applicable?(value)

  return value if blank_value?(format.format_base)

  format.format_base.gsub(/\{value\}/, value.to_s)
end