Class: StoreHours::TreeTransformer
- Inherits:
-
Parslet::Transform
- Object
- Parslet::Transform
- StoreHours::TreeTransformer
- Defined in:
- lib/store_hours/tree_transformer.rb
Overview
Convert the intermediary tree resulted from parser to the internal data structure in the format of
[{d1..d2 => [(m1..m2), (m3..m4)]},{d3..d3 => [(m5..m6)]}]
where
d is the integer value of week day (i.e, Mon = 1, Tue = 2, ..., Sun = 7),
m is the number of minutes passed from midnight (12AM).
For example, “Mon-Fri: 1AM-2AM, 10AM-5PM Sat-Sun: closed” will be converted to
[{1..5 => [(60..120), (600..1020)]}, {6..7 => [(-1..-1)]}].
Use the list of single entry hash tables instead of one hash table to preserve order of inputs.