Class: ParsableHash::Converters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/parsable_hash/converters/base.rb

Direct Known Subclasses

BigDecimal, Boolean, Date, Float, Integer, Null

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/parsable_hash/converters/base.rb', line 4

def initialize(value)
  @value = value
end

Instance Method Details

#call(&block) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/parsable_hash/converters/base.rb', line 8

def call(&block)
  try_convert
rescue => e
  if block_given?
    block.call(@value)
  else
    @value
  end
end