Class: Kortype::Parse

Inherits:
Object
  • Object
show all
Defined in:
lib/kortype/parse.rb

Constant Summary collapse

PARSE =
{
  String => :to_s,
  Integer => :to_i,
  Fixnum => :to_i,
  Float => :to_f,
  Array => :to_a,
  Hash => :to_h,
  #BigDecimal => :to_d,
  Symbol => :to_sym
}

Class Method Summary collapse

Class Method Details

.has_parse?(type) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/kortype/parse.rb', line 13

def self.has_parse? type
  PARSE.has_key? type
end

.parse(value, type) ⇒ Object



16
17
18
# File 'lib/kortype/parse.rb', line 16

def self.parse(value, type)
  value.send(PARSE[type])
end