Parent

BackgrounDRb::Trigger

Attributes

end_time[RW]

(Not documented)

repeat_interval[RW]

(Not documented)

start_time[RW]

(Not documented)

Public Class Methods

new(opts={}) click to toggle source

(Not documented)

    # File server/lib/trigger.rb, line 6
 6:     def initialize(opts={})
 7:       @start_time = Time.parse(opts[:start])
 8:       @end_time = Time.parse(opts[:end])
 9:       @repeat_interval = opts[:repeat_interval].to_i
10:     end

Public Instance Methods

fire_after_time(time) click to toggle source

(Not documented)

    # File server/lib/trigger.rb, line 12
12:     def fire_after_time(time)
13:       @start_time = time  if not @start_time
14: 
15:       # Support UNIX at-style scheduling, by just specifying a start
16:       # time.
17:       if @end_time.nil? and @repeat_interval.nil?
18:         @end_time = start_time + 1
19:         @repeat_interval = 1
20:       end
21: 
22:       case
23:       when @end_time && time > @end_time
24:         nil
25:       when time < @start_time
26:         @start_time
27:       when @repeat_interval != nil && @repeat_interval > 0
28:         time + @repeat_interval - ((time - @start_time) % @repeat_interval)
29:       end
30:     end

secsequence

--- SEC00033

seccomment

--- ""

attributes

--- 
- name: end_time
  rw: RW
  a_desc: ""
- name: repeat_interval
  rw: RW
  a_desc: ""
- name: start_time
  rw: RW
  a_desc: ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000049
    name: new
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/trigger.rb, line 6</span>\n 6:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>(<span class=\"ruby-identifier\">opts</span>={})\n 7:       <span class=\"ruby-ivar\">@start_time</span> = <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">parse</span>(<span class=\"ruby-identifier\">opts</span>[<span class=\"ruby-identifier\">:start</span>])\n 8:       <span class=\"ruby-ivar\">@end_time</span> = <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">parse</span>(<span class=\"ruby-identifier\">opts</span>[<span class=\"ruby-identifier\">:end</span>])\n 9:       <span class=\"ruby-ivar\">@repeat_interval</span> = <span class=\"ruby-identifier\">opts</span>[<span class=\"ruby-identifier\">:repeat_interval</span>].<span class=\"ruby-identifier\">to_i</span>\n\
      10:     <span class=\"ruby-keyword kw\">end</span>"
    params: (opts={})
  category: Class
  type: Public
- methods: 
  - visibility: public
    aref: M000050
    name: fire_after_time
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/trigger.rb, line 12</span>\n\
      12:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">fire_after_time</span>(<span class=\"ruby-identifier\">time</span>)\n\
      13:       <span class=\"ruby-ivar\">@start_time</span> = <span class=\"ruby-identifier\">time</span>  <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-keyword kw\">not</span> <span class=\"ruby-ivar\">@start_time</span>\n\
      14: \n\
      15:       <span class=\"ruby-comment cmt\"># Support UNIX at-style scheduling, by just specifying a start</span>\n\
      16:       <span class=\"ruby-comment cmt\"># time.</span>\n\
      17:       <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-ivar\">@end_time</span>.<span class=\"ruby-identifier\">nil?</span> <span class=\"ruby-keyword kw\">and</span> <span class=\"ruby-ivar\">@repeat_interval</span>.<span class=\"ruby-identifier\">nil?</span>\n\
      18:         <span class=\"ruby-ivar\">@end_time</span> = <span class=\"ruby-identifier\">start_time</span> <span class=\"ruby-operator\">+</span> <span class=\"ruby-value\">1</span>\n\
      19:         <span class=\"ruby-ivar\">@repeat_interval</span> = <span class=\"ruby-value\">1</span>\n\
      20:       <span class=\"ruby-keyword kw\">end</span>\n\
      21: \n\
      22:       <span class=\"ruby-keyword kw\">case</span>\n\
      23:       <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-ivar\">@end_time</span> <span class=\"ruby-operator\">&amp;&amp;</span> <span class=\"ruby-identifier\">time</span> <span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-ivar\">@end_time</span>\n\
      24:         <span class=\"ruby-keyword kw\">nil</span>\n\
      25:       <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">time</span> <span class=\"ruby-operator\">&lt;</span> <span class=\"ruby-ivar\">@start_time</span>\n\
      26:         <span class=\"ruby-ivar\">@start_time</span>\n\
      27:       <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-ivar\">@repeat_interval</span> <span class=\"ruby-operator\">!=</span> <span class=\"ruby-keyword kw\">nil</span> <span class=\"ruby-operator\">&amp;&amp;</span> <span class=\"ruby-ivar\">@repeat_interval</span> <span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-value\">0</span>\n\
      28:         <span class=\"ruby-identifier\">time</span> <span class=\"ruby-operator\">+</span> <span class=\"ruby-ivar\">@repeat_interval</span> <span class=\"ruby-operator\">-</span> ((<span class=\"ruby-identifier\">time</span> <span class=\"ruby-operator\">-</span> <span class=\"ruby-ivar\">@start_time</span>) <span class=\"ruby-operator\">%</span> <span class=\"ruby-ivar\">@repeat_interval</span>)\n\
      29:       <span class=\"ruby-keyword kw\">end</span>\n\
      30:     <span class=\"ruby-keyword kw\">end</span>"
    params: (time)
  category: Instance
  type: Public

sectitle

--- 

[Validate]

Generated with the Darkfish Rdoc Generator.