Class: CDMDEXER::FieldFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cdmdexer/field_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#formattersObject (readonly)

Returns the value of attribute formatters.



3
4
5
# File 'lib/cdmdexer/field_formatter.rb', line 3

def formatters
  @formatters
end

#valueObject (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