Class: StarTask

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

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

Instance Method Summary collapse

Constructor Details

#initialize(src = nil, debug: false) ⇒ StarTask

Returns a new instance of StarTask.



156
157
158
159
160
# File 'lib/startask.rb', line 156

def initialize(src=nil, debug: false)
  @debug = debug
  @log = []
  import src if src
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



154
155
156
# File 'lib/startask.rb', line 154

def actions
  @actions
end

#logObject (readonly)

Returns the value of attribute log.



154
155
156
# File 'lib/startask.rb', line 154

def log
  @log
end

#resultsObject (readonly)

Returns the value of attribute results.



154
155
156
# File 'lib/startask.rb', line 154

def results
  @results
end

#situationObject (readonly)

Returns the value of attribute situation.



154
155
156
# File 'lib/startask.rb', line 154

def situation
  @situation
end

#taskObject (readonly)

Returns the value of attribute task.



154
155
156
# File 'lib/startask.rb', line 154

def task
  @task
end

Instance Method Details

#doneObject Also known as: completed



162
163
164
# File 'lib/startask.rb', line 162

def done()
  logit :completed
end

#import(raws) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/startask.rb', line 168

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.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.import(kvx.action[:items])
  @results = Results.new.import(kvx.result[:items])

end

#startedObject

adds a status message to the log



210
211
212
# File 'lib/startask.rb', line 210

def started()
  logit :started
end

#statusObject



214
215
216
# File 'lib/startask.rb', line 214

def status()
  @log.last
end

#stoppedObject



218
219
220
# File 'lib/startask.rb', line 218

def stopped()
  logit :stopped
end