Class: ActionItem

Inherits:
Object
  • Object
show all
Includes:
RecordHelper
Defined in:
lib/startask.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RecordHelper

#generate_id, #logit

Constructor Details

#initialize(s, callback = nil) ⇒ ActionItem

Returns a new instance of ActionItem.



27
28
29
30
31
32
33
34
# File 'lib/startask.rb', line 27

def initialize(s, callback=nil)
  
  @id = generate_id()
  @title = s
  @log = []
  @callback = callback
  
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



25
26
27
# File 'lib/startask.rb', line 25

def id
  @id
end

#logObject (readonly)

Returns the value of attribute log.



25
26
27
# File 'lib/startask.rb', line 25

def log
  @log
end

Instance Method Details

#doneObject Also known as: completed



36
37
38
# File 'lib/startask.rb', line 36

def done()
  logaction :completed
end

#startedObject



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

def started()
  logaction :started
end

#statusObject



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

def status()
  @log.last ? @log.last : []
end

#status=(status) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/startask.rb', line 58

def status=(status)
  
  case status
  when :done
    done()
  when :started
    started()
  end
  
end

#stoppedObject



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

def stopped()
  logaction :stopped
end

#to_sObject



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

def to_s()
  @title
end

#to_xmlObject



69
70
71
72
73
74
# File 'lib/startask.rb', line 69

def to_xml()
  
  h = {id: @id, status: status().join(' ')}
  Rexle::Element.new(:action, attributes: h, value: @title)
  
end