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.



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

def initialize(yaml)
  @hash = YAML::load(yaml)
  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.



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

def hash
  @hash
end