class TJSON::Object

TJSON object type (i.e. hash/dict-alike)

Public Instance Methods

[]=(tagged_name, value) click to toggle source
Calls superclass method
# File lib/tjson/object.rb, line 6
def []=(tagged_name, value)
  # NOTE: this regex is sloppy. The real parsing is performed in TJSON::DataType#parse
  result = tagged_name.match(/\A(?<name>.*):(?<tag>[A-Za-z0-9\<]+[\>]*)\z/)

  raise ParseError, "invalid tag: #{tagged_name.inspect}" unless result
  raise DuplicateNameError, "duplicate member name: #{result[:name].inspect}" if key?(result[:name])

  type = TJSON::DataType.parse(result[:tag])
  super(result[:name], type.decode(value))
end