class TJSON::DataType::UnsignedInt

Unsigned 64-bit integer

Public Instance Methods

decode(str) click to toggle source
# File lib/tjson/datatype/integer.rb, line 37
def decode(str)
  raise TJSON::TypeError, "expected String, got #{str.class}: #{str.inspect}" unless str.is_a?(::String)
  raise TJSON::ParseError, "invalid integer: #{str.inspect}" unless str =~ /\A(0|[1-9][0-9]*)\z/

  result = Integer(str, 10)
  raise TJSON::ParseError, "oversized integer: #{result}" if result > 18_446_744_073_709_551_615

  result
end
tag() click to toggle source
# File lib/tjson/datatype/integer.rb, line 33
def tag
  "u"
end