Class: StarTask
Overview
task dictionary
import (method) Imports a new “task” which includes a STAR document outline done (method) The task has been completed completed - alias of method done status (method) returns the most recent status from the task log log (attr) returns an Array object containing a timeline of status messages in chronological order progress (method) returns the most recent action completed or started duration (method) returns the actual duration type (attr) Frequency type e.g. (daily, weekly, monthly) estimate_duration (attr) OPTIONAL. the estimate duration is explicitly declared in the STAR document or is calculated from estimate durations in the actions if declared. actions (method) returns the Actions object location (attr) set or get the current physical location started (method) adds a status message to the log
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#situation ⇒ Object
readonly
Returns the value of attribute situation.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #done ⇒ Object (also: #completed)
- #find(id) ⇒ Object
- #import(raws) ⇒ Object
-
#initialize(src = nil, debug: false) ⇒ StarTask
constructor
A new instance of StarTask.
- #log(detail: false) ⇒ Object
- #logupdate(item) ⇒ Object
-
#started ⇒ Object
adds a status message to the log.
- #status ⇒ Object
- #status=(s) ⇒ Object
- #stopped ⇒ Object
- #to_xml ⇒ Object
Methods included from RecordHelper
Constructor Details
#initialize(src = nil, debug: false) ⇒ StarTask
Returns a new instance of StarTask.
276 277 278 279 280 281 282 283 284 |
# File 'lib/startask.rb', line 276 def initialize(src=nil, debug: false) @debug = debug @id = generate_id() @log = [] @status = '' read src if src end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
274 275 276 |
# File 'lib/startask.rb', line 274 def actions @actions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
274 275 276 |
# File 'lib/startask.rb', line 274 def id @id end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
274 275 276 |
# File 'lib/startask.rb', line 274 def results @results end |
#situation ⇒ Object (readonly)
Returns the value of attribute situation.
274 275 276 |
# File 'lib/startask.rb', line 274 def situation @situation end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
274 275 276 |
# File 'lib/startask.rb', line 274 def task @task end |
Instance Method Details
#done ⇒ Object Also known as: completed
286 287 288 |
# File 'lib/startask.rb', line 286 def done() logtask :completed end |
#find(id) ⇒ Object
292 293 294 295 296 297 298 299 300 |
# File 'lib/startask.rb', line 292 def find(id) if @id == id then return self else @actions.find id end end |
#import(raws) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/startask.rb', line 302 def import(raws) s, _ = RXFHelper.read raws puts 's: ' + s.inspect if @debug obj = if s.lstrip[0] == '#' then a = s.split(/^#+ /) a.shift rawh = a.map do |x| rawlabel, body = x.split(/\n/,2) [rawlabel.rstrip.downcase.gsub(/\s+/, '_').to_sym, body.strip.gsub(/^(\s*)[\*\+] /,'\1')] end.to_h h = {} h[:situation] = rawh[:situation] h[:task] = rawh[:task] h[:action] = {items: LineTree.new(rawh[:action]).to_a(normalize: true)} h[:result] = {items: LineTree.new(rawh[:result]).to_a(normalize: true)} h else s end puts 'obj: ' + obj.inspect if @debug kvx = Kvx.new obj @situation = kvx.situation @task = kvx.task @actions = Actions.new(self).import(kvx.action[:items]) @results = Results.new(self).import(kvx.result[:items]) end |
#log(detail: false) ⇒ Object
342 343 344 345 |
# File 'lib/startask.rb', line 342 def log(detail: false) #todo detail ? @log.map {|x| [@id, x[-1], x[0]]} : @log end |
#logupdate(item) ⇒ Object
347 348 349 |
# File 'lib/startask.rb', line 347 def logupdate(item) @log << item end |
#started ⇒ Object
adds a status message to the log
353 354 355 |
# File 'lib/startask.rb', line 353 def started() logtask :started end |
#status ⇒ Object
357 358 359 |
# File 'lib/startask.rb', line 357 def status() @status end |
#status=(s) ⇒ Object
361 362 363 |
# File 'lib/startask.rb', line 361 def status=(s) @status = s end |
#stopped ⇒ Object
365 366 367 |
# File 'lib/startask.rb', line 365 def stopped() logtask :stopped end |
#to_xml ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/startask.rb', line 369 def to_xml() situation = Rexle::Element.new( :situation, value: @situation) task = Rexle::Element.new( :task, value: @task) doc = Rexle.new() doc.add Rexle::Element.new(:star) doc.root.attributes[:id] = @id doc.root.add situation doc.root.add task doc.root.add @actions.to_xml doc.root.add @results.to_xml logx = log(detail: true) + @actions.log lognode = Rexle::Element.new(:log) logx.sort_by {|x| x[1]}.reverse.each do |x| attr = {id: x[0], timestamp: x[1]} val = "[%s]" % x[2] val += ' ' + x[3] if x[3] lognode.add Rexle::Element.new( :li, attributes: attr, value: val) end doc.root.add lognode doc.root.xml pretty: true end |