class Gom::Core::Primitive

Constants

Formatters
Parsers
TypeCodes
TypeMap

Public Class Methods

decode(txt, type = :txt) click to toggle source

text, type -> value

# File lib/gom/core/primitive.rb, line 43
def self.decode txt, type = :txt
  parser = type && Parsers[type.to_sym]
  parser ? parser.call(txt) : txt
end
encode(value) click to toggle source

value -> text, type

# File lib/gom/core/primitive.rb, line 49
def self.encode value
  type = TypeMap[value.class] || :txt
  formatter = Formatters[type]
  [ formatter.call(value), type]
end