Class: Ducktape::Converter
- Inherits:
-
Object
- Object
- Ducktape::Converter
- Defined in:
- lib/ducktape/converter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #convert(value) ⇒ Object
-
#initialize(convert = ->(v){v}, revert = nil) ⇒ Converter
constructor
A new instance of Converter.
- #revert(value) ⇒ Object
Constructor Details
#initialize(convert = ->(v){v}, revert = nil) ⇒ Converter
Returns a new instance of Converter.
3 4 5 |
# File 'lib/ducktape/converter.rb', line 3 def initialize(convert = ->(v){v}, revert = nil) @cnv, @rev = convert, revert || convert end |
Class Method Details
.convert(value) ⇒ Object
15 16 17 |
# File 'lib/ducktape/converter.rb', line 15 def self.convert(value) value end |
.revert(value) ⇒ Object
19 20 21 |
# File 'lib/ducktape/converter.rb', line 19 def self.revert(value) value end |
Instance Method Details
#convert(value) ⇒ Object
7 8 9 |
# File 'lib/ducktape/converter.rb', line 7 def convert(value) @cnv.(value) end |
#revert(value) ⇒ Object
11 12 13 |
# File 'lib/ducktape/converter.rb', line 11 def revert(value) @rev.(value) end |