Class: Mo2tex::ExclusionManager
- Inherits:
-
Object
- Object
- Mo2tex::ExclusionManager
- Defined in:
- lib/mo2tex/exclusion_manager.rb
Instance Attribute Summary collapse
-
#end_period ⇒ Object
readonly
Returns the value of attribute end_period.
-
#excluded ⇒ Object
readonly
Returns the value of attribute excluded.
-
#start_period ⇒ Object
readonly
Returns the value of attribute start_period.
Instance Method Summary collapse
- #<<(dts) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(exl_array, sp, ep) ⇒ ExclusionManager
constructor
A new instance of ExclusionManager.
- #out_of_range?(d) ⇒ Boolean
- #skip?(d) ⇒ Boolean
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_period ⇒ Object (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 |
#excluded ⇒ Object (readonly)
Returns the value of attribute excluded.
9 10 11 |
# File 'lib/mo2tex/exclusion_manager.rb', line 9 def excluded @excluded end |
#start_period ⇒ Object (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
28 29 30 |
# File 'lib/mo2tex/exclusion_manager.rb', line 28 def empty? return self.excluded.empty? end |
#out_of_range?(d) ⇒ 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
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 |