Class: TOML::Keyvalue

Inherits:
Object
  • Object
show all
Defined in:
lib/toml/keyvalue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ Keyvalue



7
8
9
# File 'lib/toml/keyvalue.rb', line 7

def initialize(key, value)
  @key, @value = key, value
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/toml/keyvalue.rb', line 5

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/toml/keyvalue.rb', line 5

def value
  @value
end

Instance Method Details

#accept_visitor(parser) ⇒ Object



17
18
19
# File 'lib/toml/keyvalue.rb', line 17

def accept_visitor(parser)
  parser.visit_keyvalue self
end

#assign(hash, symbolize_keys = false) ⇒ Object



11
12
13
14
15
# File 'lib/toml/keyvalue.rb', line 11

def assign(hash, symbolize_keys = false)
  key = symbolize_keys ? @key.to_sym : @key
  fail ValueOverwriteError if hash[key]
  hash[key] = @value
end