Class: SleepingKingStudios::Tasks::Task

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
Thor::Shell
Defined in:
lib/sleeping_king_studios/tasks/task.rb

Overview

Encapsulates a Thor task as a class object.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

description, option, task_name

Constructor Details

#initialize(options) ⇒ Task

Returns a new instance of Task.

Parameters:

  • options (Hash)

    The command-line options passed in via Thor.



59
60
61
# File 'lib/sleeping_king_studios/tasks/task.rb', line 59

def initialize options
  @options = options
end

Instance Attribute Details

#optionsHash (readonly)

Returns The command-line options passed in via Thor.

Returns:

  • (Hash)

    The command-line options passed in via Thor.



64
65
66
# File 'lib/sleeping_king_studios/tasks/task.rb', line 64

def options
  @options
end

Instance Method Details

#call(*_args) ⇒ Object

Performs the task with the given arguments. Overriden by subclasses.



67
# File 'lib/sleeping_king_studios/tasks/task.rb', line 67

def call *_args; end

#mute!Object

Mutes the task.



70
71
72
# File 'lib/sleeping_king_studios/tasks/task.rb', line 70

def mute!
  @mute = true
end

#mute?Boolean Also known as: muted?

Returns True if the task has been muted, otherwise false.

Returns:

  • (Boolean)

    True if the task has been muted, otherwise false.



75
76
77
# File 'lib/sleeping_king_studios/tasks/task.rb', line 75

def mute?
  !!@mute
end

#say(*args) ⇒ Object

Prints the given message unless the task has been muted.

See Also:

  • Thor::Shell#say.


83
84
85
86
87
# File 'lib/sleeping_king_studios/tasks/task.rb', line 83

def say *args
  return if mute?

  super
end