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.
173 174 175 176 177 178 |
# File 'lib/tomlrb/handler.rb', line 173 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
171 172 173 |
# File 'lib/tomlrb/handler.rb', line 171 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type
171 172 173 |
# File 'lib/tomlrb/handler.rb', line 171 def type @type end |
Instance Method Details
#<<(key_type_declared) ⇒ Object
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/tomlrb/handler.rb', line 184 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
195 196 197 |
# File 'lib/tomlrb/handler.rb', line 195 def clear_children @children.clear end |
#declared? ⇒ Boolean
180 181 182 |
# File 'lib/tomlrb/handler.rb', line 180 def declared? @declared end |