Class: Fugit::Nat::SlotGroup
- Inherits:
-
Object
- Object
- Fugit::Nat::SlotGroup
- Defined in:
- lib/fugit/nat.rb
Instance Method Summary collapse
-
#initialize(slots) ⇒ SlotGroup
constructor
A new instance of SlotGroup.
- #to_crons(opts) ⇒ Object
Constructor Details
#initialize(slots) ⇒ SlotGroup
Returns a new instance of SlotGroup.
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
# File 'lib/fugit/nat.rb', line 622 def initialize(slots) #puts "SlotGroup.new " + slots.inspect @slots = {} @hms = [] slots.each do |s| if s.key == :hm #ls = @hms.last; @hms.pop if ls && ls.key == :hm && ls.weak == true @hms << s elsif hs = @slots[s.key] hs.append(s) else @slots[s.key] = s end end if @slots[:monthday] || @slots[:weekday] @hms << make_slot(:hm, 0, 0) if @hms.empty? elsif @slots[:month] @hms << make_slot(:hm, 0, 0) if @hms.empty? @slots[:monthday] ||= make_slot(:monthday, 1) end end |
Instance Method Details
#to_crons(opts) ⇒ Object
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
# File 'lib/fugit/nat.rb', line 647 def to_crons(opts) multi = opts.has_key?(:multi) ? opts[:multi] : false hms = determine_hms if multi == :fail && hms.count > 1 fail(ArgumentError.new( "multiple crons in #{opts[:_s].inspect} - #{@slots.inspect}")) elsif multi == true hms.collect { |hm| parse_cron(hm, opts) } else parse_cron(hms.first, opts) end end |