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.



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

def initialize(original_hash)
  @hash = original_hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

Instance Method Details

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

Yields:

  • (schedule)


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

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