Class: IceCube::HashParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ice_cube/parsers/hash_parser.rb

Direct Known Subclasses

YamlParser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_hash) ⇒ HashParser

Returns a new instance of HashParser.


6
7
8
# File 'lib/ice_cube/parsers/hash_parser.rb', line 6

def initialize(original_hash)
  @hash = original_hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash


4
5
6
# File 'lib/ice_cube/parsers/hash_parser.rb', line 4

def hash
  @hash
end

Instance Method Details

#to_schedule {|schedule| ... } ⇒ Object

Yields:

  • (schedule)

10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ice_cube/parsers/hash_parser.rb', line 10

def to_schedule
  data = normalize_keys(hash)
  schedule = IceCube::Schedule.new parse_time(data[:start_time])
  apply_duration schedule, data
  apply_end_time schedule, data
  apply_rrules schedule, data
  apply_exrules schedule, data
  apply_rtimes schedule, data
  apply_extimes schedule, data
  yield schedule if block_given?
  schedule
end