Class: Loki::Task::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/loki/task/base.rb

Direct Known Subclasses

Proc, Task

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/loki/task/base.rb', line 7

def initialize(name)
  @name = name
  @parent = nil
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/loki/task/base.rb', line 4

def name
  @name
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/loki/task/base.rb', line 26

def done?
  false
end

#list(&block) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/loki/task/base.rb', line 36

def list(&block)
  Loki.logger.line
  Loki.logger.puts "#{self.class}: #{@name}, done: #{done?}, time: #{time}", "-"
  Loki.logger.push
  yield if block_given?
  Loki.logger.pull
  Loki.logger.line
end

#sham?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/loki/task/base.rb', line 31

def sham?
  false
end

#timeObject



21
22
23
# File 'lib/loki/task/base.rb', line 21

def time
  Time.now
end

#work(&block) ⇒ Object



13
14
15
16
17
18
# File 'lib/loki/task/base.rb', line 13

def work(&block)
  Loki.logger.puts "#{@name}" if Loki.logger.indented?
  Loki.logger.push
  yield if block_given?
  Loki.logger.pull
end