Class: Shellac::ConfigClass::Task

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/shellac/config/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order = 0, &task) ⇒ Task



8
9
10
11
# File 'lib/shellac/config/task.rb', line 8

def initialize(order = 0, &task)
  @order = order
  @task = task
end

Instance Attribute Details

#orderObject

Returns the value of attribute order.



6
7
8
# File 'lib/shellac/config/task.rb', line 6

def order
  @order
end

#taskObject

Returns the value of attribute task.



6
7
8
# File 'lib/shellac/config/task.rb', line 6

def task
  @task
end

Instance Method Details

#<=>(another_task) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/shellac/config/task.rb', line 13

def <=>(another_task)
  if @order < another_task.order
    -1
  elsif @order > another_task.order
    1
  else
    if @task.to_s < another_task.task.to_s
      -1
    elsif @task.to_s > another_task.task.to_s
      1
    else
      0
    end
  end
end

#call(*args) ⇒ Object



29
30
31
# File 'lib/shellac/config/task.rb', line 29

def call(*args)
  @task.call(*args) if @task
end