Class: Serf::Handler::Task

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/serf/handler/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :query, name = nil, order = 0, description = '', &task) ⇒ Task

Returns a new instance of Task.



8
9
10
11
12
13
14
# File 'lib/serf/handler/task.rb', line 8

def initialize(type = :query, name = nil, order = 0, description = '', &task)
  @order = order
  @type = type
  @name = name
  @description = description
  @task = task
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/serf/handler/task.rb', line 6

def description
  @description
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/serf/handler/task.rb', line 6

def name
  @name
end

#orderObject

Returns the value of attribute order.



6
7
8
# File 'lib/serf/handler/task.rb', line 6

def order
  @order
end

#taskObject

Returns the value of attribute task.



6
7
8
# File 'lib/serf/handler/task.rb', line 6

def task
  @task
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/serf/handler/task.rb', line 6

def type
  @type
end

Instance Method Details

#<=>(another_task) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/serf/handler/task.rb', line 16

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



32
33
34
# File 'lib/serf/handler/task.rb', line 32

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