Class: Mo2tex::ExclusionManager

Inherits:
Object
  • Object
show all
Defined in:
lib/mo2tex/exclusion_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exl_array, sp, ep) ⇒ ExclusionManager

Returns a new instance of ExclusionManager.



11
12
13
14
15
# File 'lib/mo2tex/exclusion_manager.rb', line 11

def initialize(exl_array, sp, ep)
  @start_period = DateTime.parse(sp.to_s)
  @end_period = DateTime.parse(ep.to_s)
  @excluded = parse(exl_array)
end

Instance Attribute Details

#end_periodObject (readonly)

Returns the value of attribute end_period.



9
10
11
# File 'lib/mo2tex/exclusion_manager.rb', line 9

def end_period
  @end_period
end

#excludedObject (readonly)

Returns the value of attribute excluded.



9
10
11
# File 'lib/mo2tex/exclusion_manager.rb', line 9

def excluded
  @excluded
end

#start_periodObject (readonly)

Returns the value of attribute start_period.



9
10
11
# File 'lib/mo2tex/exclusion_manager.rb', line 9

def start_period
  @start_period
end

Instance Method Details

#<<(dts) ⇒ Object



32
33
34
35
36
# File 'lib/mo2tex/exclusion_manager.rb', line 32

def <<(dts)
  arg = dts.is_a?(Array) ? dts : [ dts ]
  result = parse(arg)
  self.excluded.concat(result)
end

#empty?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mo2tex/exclusion_manager.rb', line 28

def empty?
  return self.excluded.empty?
end

#out_of_range?(d) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/mo2tex/exclusion_manager.rb', line 23

def out_of_range?(d)
  dt = DateTime.parse(d.to_s)
  return (dt < self.start_period || dt > self.end_period)
end

#skip?(d) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/mo2tex/exclusion_manager.rb', line 17

def skip?(d)
  result = false
  self.excluded.each { |ed| result |= ed.skip?(d) }
  return result
end