Class: GandiV5::Data::Converter
- Inherits:
-
Object
- Object
- GandiV5::Data::Converter
- Defined in:
- lib/gandi_v5/data/converter.rb,
lib/gandi_v5/data/converter/time.rb,
lib/gandi_v5/data/converter/symbol.rb,
lib/gandi_v5/data/converter/array_of.rb
Overview
Namespace for converters to/from Gandi’s format.
Defined Under Namespace
Classes: ArrayOf, Symbol, Time
Instance Method Summary collapse
- #from_gandi(value) ⇒ Object
-
#initialize(from_gandi: nil, to_gandi: nil) ⇒ Converter
constructor
Initialize a new simple converter.
- #to_gandi(value) ⇒ Object
Constructor Details
#initialize(from_gandi: nil, to_gandi: nil) ⇒ Converter
Initialize a new simple converter. The passed procs will be run at the appropriate time.
11 12 13 14 |
# File 'lib/gandi_v5/data/converter.rb', line 11 def initialize(from_gandi: nil, to_gandi: nil) @from_gandi_proc = from_gandi @to_gandi_proc = to_gandi end |
Instance Method Details
#from_gandi(value) ⇒ Object
26 27 28 29 30 |
# File 'lib/gandi_v5/data/converter.rb', line 26 def from_gandi(value) return value unless from_gandi_proc from_gandi_proc.call value end |
#to_gandi(value) ⇒ Object
18 19 20 21 22 |
# File 'lib/gandi_v5/data/converter.rb', line 18 def to_gandi(value) return value unless to_gandi_proc to_gandi_proc.call value end |