Class: Bumbleworks::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/bumbleworks/schedule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/bumbleworks/schedule.rb', line 3

def id
  @id
end

#original_hashObject (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

.allObject



6
7
8
9
10
# File 'lib/bumbleworks/schedule.rb', line 6

def all
  Bumbleworks.dashboard.schedules.map do |hsh|
    new(hsh)
  end
end

.countObject



12
13
14
# File 'lib/bumbleworks/schedule.rb', line 12

def count
  all.count
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/bumbleworks/schedule.rb', line 22

def ==(other)
  @id == other.id
end

#expressionObject



34
35
36
# File 'lib/bumbleworks/schedule.rb', line 34

def expression
  Bumbleworks::Expression.from_fei(@original_hash['owner'])
end

#next_atObject



46
47
48
# File 'lib/bumbleworks/schedule.rb', line 46

def next_at
  Time.parse(@original_hash['at'])
end

#once?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/bumbleworks/schedule.rb', line 42

def once?
  !repeating?
end

#original_planObject



50
51
52
# File 'lib/bumbleworks/schedule.rb', line 50

def original_plan
  @original_hash['original']
end

#processObject



30
31
32
# File 'lib/bumbleworks/schedule.rb', line 30

def process
  Bumbleworks::Process.new(wfid)
end

#repeating?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/bumbleworks/schedule.rb', line 38

def repeating?
  ['cron', 'every'].include? expression.tree[0]
end

#test_clauseObject



54
55
56
# File 'lib/bumbleworks/schedule.rb', line 54

def test_clause
  expression.tree[1]['test']
end

#wfidObject



26
27
28
# File 'lib/bumbleworks/schedule.rb', line 26

def wfid
  @original_hash['wfid']
end