Class: Tomlrb::Key
- Inherits:
-
Object
- Object
- Tomlrb::Key
- Defined in:
- lib/tomlrb/handler.rb
Defined Under Namespace
Classes: KeyConflict
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #<<(key_type_declared) ⇒ Object
- #clear_children ⇒ Object
- #declared? ⇒ Boolean
-
#initialize(key, type, declared = false) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(key, type, declared = false) ⇒ Key
Returns a new instance of Key.
208 209 210 211 212 213 |
# File 'lib/tomlrb/handler.rb', line 208 def initialize(key, type, declared = false) @key = key @type = type @declared = declared @children = {} end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
206 207 208 |
# File 'lib/tomlrb/handler.rb', line 206 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
206 207 208 |
# File 'lib/tomlrb/handler.rb', line 206 def type @type end |
Instance Method Details
#<<(key_type_declared) ⇒ Object
219 220 221 222 223 224 225 226 227 228 |
# File 'lib/tomlrb/handler.rb', line 219 def <<(key_type_declared) key, type, declared, is_array_of_tables = key_type_declared existed = @children[key] validate_already_declared_as_different_key(type, declared, existed) validate_already_declared_as_non_array_table(type, is_array_of_tables, declared, existed) validate_path_already_created_as_different_type(type, declared, existed) validate_path_already_declared_as_different_type(type, declared, existed) validate_already_declared_as_same_key(declared, existed) @children[key] = existed || self.class.new(key, type, declared) end |
#clear_children ⇒ Object
230 231 232 |
# File 'lib/tomlrb/handler.rb', line 230 def clear_children @children.clear end |
#declared? ⇒ Boolean
215 216 217 |
# File 'lib/tomlrb/handler.rb', line 215 def declared? @declared end |