Class: CDMDEXER::FieldFormatter
- Inherits:
-
Object
- Object
- CDMDEXER::FieldFormatter
- Defined in:
- lib/cdmdexer/field_formatter.rb
Instance Attribute Summary collapse
-
#formatters ⇒ Object
readonly
Returns the value of attribute formatters.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #format! ⇒ Object
-
#initialize(value: {}, formatters: [DefaultFormatter]) ⇒ FieldFormatter
constructor
A new instance of FieldFormatter.
Constructor Details
#initialize(value: {}, formatters: [DefaultFormatter]) ⇒ FieldFormatter
Returns a new instance of FieldFormatter.
4 5 6 7 |
# File 'lib/cdmdexer/field_formatter.rb', line 4 def initialize(value: {}, formatters: [DefaultFormatter]) @value = value @formatters = formatters end |
Instance Attribute Details
#formatters ⇒ Object (readonly)
Returns the value of attribute formatters.
3 4 5 |
# File 'lib/cdmdexer/field_formatter.rb', line 3 def formatters @formatters end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/cdmdexer/field_formatter.rb', line 3 def value @value end |
Instance Method Details
#format! ⇒ Object
9 10 11 |
# File 'lib/cdmdexer/field_formatter.rb', line 9 def format! formatters.reduce(value) { |memo, formatter| formatter.format(memo) } end |