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