Class: ActionItem
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #done ⇒ Object (also: #completed)
- #find(id) ⇒ Object
-
#initialize(s, callback = nil, id: nil) ⇒ ActionItem
constructor
A new instance of ActionItem.
- #log(detail: false) ⇒ Object
- #logupdate(item) ⇒ Object
- #started ⇒ Object
- #status ⇒ Object
- #status=(status) ⇒ Object
- #stopped ⇒ Object
- #to_s ⇒ Object
- #to_xml ⇒ Object
Methods included from RecordHelper
Constructor Details
#initialize(s, callback = nil, id: nil) ⇒ ActionItem
Returns a new instance of ActionItem.
28 29 30 31 32 33 34 35 |
# File 'lib/startask.rb', line 28 def initialize(s, callback=nil, id: nil) @id = id || generate_id() @title = s @log = [] @callback = callback end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
26 27 28 |
# File 'lib/startask.rb', line 26 def id @id end |
Instance Method Details
#done ⇒ Object Also known as: completed
37 38 39 |
# File 'lib/startask.rb', line 37 def done() logaction :completed end |
#find(id) ⇒ Object
43 44 45 |
# File 'lib/startask.rb', line 43 def find(id) return self if id == @id end |
#log(detail: false) ⇒ Object
47 48 49 |
# File 'lib/startask.rb', line 47 def log(detail: false) detail ? @log.map {|x| [@id, x[-1], x[0], @title]} : @log end |
#logupdate(item) ⇒ Object
51 52 53 |
# File 'lib/startask.rb', line 51 def logupdate(item) @log << item end |
#started ⇒ Object
59 60 61 |
# File 'lib/startask.rb', line 59 def started() logaction :started end |
#status ⇒ Object
63 64 65 |
# File 'lib/startask.rb', line 63 def status() @log.last ? @log.last : [] end |
#status=(status) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/startask.rb', line 71 def status=(status) case status when :done done() when :started started() end end |
#stopped ⇒ Object
67 68 69 |
# File 'lib/startask.rb', line 67 def stopped() logaction :stopped end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/startask.rb', line 55 def to_s() @title end |
#to_xml ⇒ Object
82 83 84 85 86 87 |
# File 'lib/startask.rb', line 82 def to_xml() h = {id: @id, status: status().join(' ')} Rexle::Element.new(:action, attributes: h, value: @title) end |