-
Notifications
You must be signed in to change notification settings - Fork 3
TUTO~3b: Adding the remaining atomic types
Up to now our TOML implementation supported only unquoted keys, this time we want to cover quoted keys as well:
"this is a quoted key" = true
A quoted key resembles closely to a string, one may be therefore tempted to represent it with a TOMLString
instance.
This would be incorrect, although quoted keys and strings look similar they differ from a syntax point of view:
- A quoted key may appear on the left-hand side of a key-value pair,
- A string, as a data value, is allowed on the right side only.
Furthermore, they are semantically different: a quoted key is ... a key.
The key class hierarchy is changed as follows:
The toml_datatype.rb file starts with the following lines:
# Re-use datatypes defined in iteration 2
require_relative '../iter_2/toml_datatype'
In other words, we reuse “as is” the data types already implemented in the previous iteration.
That's a pretty good news.
What is more, the new data classes fit neatly in the existing data type hierarchy:
Legend:
- In light gray, the classes from iteration 2,
- In light yellow, the new class implemented for the present iteration.
Here are the date / time data types implemented in this third iteration:
TOML Data type | Examples | Implementation |
---|---|---|
Offset Date-Time | 1979-05-27T00:32:00-07:00 | TOMLOffsetDateTime |
Local Date-Time | 1979-05-27T07:32:00 | TOMLLocalDateTime |
Local Date | 1979-05-27 | TOMLLocalDate |
Local Time | 7:32:00 | TOMLLocalTime |