class FlatMap::Mapping::Reader::Formatted
Formatted
reader reads the value the same as Basic
reader does, but additionally performs value postprocessing. All processing methods are defined within {Formatted::Formats} module. The method is chosen based on the :format option when the mapping is defined.
Public Class Methods
Initialize the reader with a mapping
and a format
.
@param [FlatMap::Mapping] mapping @param [Symbol] format
# File lib/flat_map/mapping/reader/formatted.rb, line 17 def initialize(mapping, format) @mapping, @format = mapping, format end
Public Instance Methods
Read the value just like the {Basic} reader does, but additionally send the returned value to its format method.
Additional arguments will be passed to formatting function of the mapping’s format.
@return [Object] formatted value
FlatMap::Mapping::Reader::Basic#read
# File lib/flat_map/mapping/reader/formatted.rb, line 28 def read(*args) format_value(super, *args) end
Private Instance Methods
Send the value
to the format method, defined in the {Format} module and specified upon reader initialization.
Additional optional arguments are passed as well.
@param [Object] value @return [Object] formatted value
# File lib/flat_map/mapping/reader/formatted.rb, line 39 def format_value(value, *args) send(@format, value, *args) end