Sha256: aa8b24c14bf14c2bdace71fc695623020f53b831aa4c0fa0c9749455f140dacc
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
module Pige::Client class ChunkScheduler attr_accessor :day, :default_attributes, :dry_run alias_method :dry_run?, :dry_run def initialize(day = Date.today) self.day = day self.default_attributes = { :format => "wav" } end def self.define(&block) yield new end def on(criteria, &block) if day.send("#{criteria}?") puts "Scheduling #{criteria}" instance_exec &block end end def create(attributes = {}) attributes = default_attributes.merge(attributes) [:begin, :end].each do |endpoint| attributes[endpoint] = Time.parse(attributes[endpoint], day) if String === attributes[endpoint] end if duration = attributes.delete(:duration) if attributes[:begin] attributes[:end] = attributes[:begin] + duration else attributes[:begin] = attributes[:end] - duration end end if margin = attributes.delete(:margin) attributes[:begin] -= margin attributes[:end] += margin end if attributes[:title] =~ /%[dmyHMY]/ attributes[:title] = day.strftime(attributes[:title]) end puts "Create Chunk with #{attributes.inspect}" Pige::Chunk.create attributes unless dry_run? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tryphon-pige-client-0.0.1 | lib/pige/client/chunk_scheduler.rb |