Class: Bumbleworks::Schedule
- Inherits:
-
Object
- Object
- Bumbleworks::Schedule
- Defined in:
- lib/bumbleworks/schedule.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#original_hash ⇒ Object
readonly
Returns the value of attribute original_hash.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #expression ⇒ Object
-
#initialize(schedule_hash) ⇒ Schedule
constructor
A new instance of Schedule.
- #next_at ⇒ Object
- #once? ⇒ Boolean
- #original_plan ⇒ Object
- #process ⇒ Object
- #repeating? ⇒ Boolean
- #test_clause ⇒ Object
- #wfid ⇒ Object
Constructor Details
#initialize(schedule_hash) ⇒ Schedule
Returns a new instance of Schedule.
17 18 19 20 |
# File 'lib/bumbleworks/schedule.rb', line 17 def initialize(schedule_hash) @original_hash = schedule_hash @id = @original_hash['_id'] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/bumbleworks/schedule.rb', line 3 def id @id end |
#original_hash ⇒ Object (readonly)
Returns the value of attribute original_hash.
3 4 5 |
# File 'lib/bumbleworks/schedule.rb', line 3 def original_hash @original_hash end |
Class Method Details
.all ⇒ Object
6 7 8 9 10 |
# File 'lib/bumbleworks/schedule.rb', line 6 def all Bumbleworks.dashboard.schedules.map do |hsh| new(hsh) end end |
.count ⇒ Object
12 13 14 |
# File 'lib/bumbleworks/schedule.rb', line 12 def count all.count end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 |
# File 'lib/bumbleworks/schedule.rb', line 22 def ==(other) return false unless other.is_a?(self.class) @id == other.id end |
#expression ⇒ Object
35 36 37 |
# File 'lib/bumbleworks/schedule.rb', line 35 def expression Bumbleworks::Expression.from_fei(@original_hash['owner']) end |
#next_at ⇒ Object
47 48 49 |
# File 'lib/bumbleworks/schedule.rb', line 47 def next_at Time.parse(@original_hash['at']) end |
#once? ⇒ Boolean
43 44 45 |
# File 'lib/bumbleworks/schedule.rb', line 43 def once? !repeating? end |
#original_plan ⇒ Object
51 52 53 |
# File 'lib/bumbleworks/schedule.rb', line 51 def original_plan @original_hash['original'] end |
#process ⇒ Object
31 32 33 |
# File 'lib/bumbleworks/schedule.rb', line 31 def process Bumbleworks::Process.new(wfid) end |
#repeating? ⇒ Boolean
39 40 41 |
# File 'lib/bumbleworks/schedule.rb', line 39 def repeating? ['cron', 'every'].include? expression.tree[0] end |
#test_clause ⇒ Object
55 56 57 |
# File 'lib/bumbleworks/schedule.rb', line 55 def test_clause expression.tree[1]['test'] end |
#wfid ⇒ Object
27 28 29 |
# File 'lib/bumbleworks/schedule.rb', line 27 def wfid @original_hash['wfid'] end |