Class: IceCube::YamlParser

Inherits:
HashParser show all
Defined in:
lib/ice_cube/parsers/yaml_parser.rb

Constant Summary collapse

SERIALIZED_START =
/start_(?:time|date): .+(?<tz>(?:-|\+)\d{2}:\d{2})$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HashParser

#to_schedule

Constructor Details

#initialize(yaml) ⇒ YamlParser

Returns a new instance of YamlParser.



9
10
11
12
13
14
15
# File 'lib/ice_cube/parsers/yaml_parser.rb', line 9

def initialize(yaml)
  @hash = YAML.safe_load(yaml, permitted_classes: [Date, Symbol, Time], aliases: true)
  yaml.match SERIALIZED_START do |match|
    start_time = hash[:start_time] || hash[:start_date]
    TimeUtil.restore_deserialized_offset start_time, match[:tz]
  end
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



7
8
9
# File 'lib/ice_cube/parsers/yaml_parser.rb', line 7

def hash
  @hash
end