Class: Semaph::Shells::Project::WorkflowsSelectCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/semaph/shells/project/workflows_select_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_collection) ⇒ WorkflowsSelectCommand

Returns a new instance of WorkflowsSelectCommand.



10
11
12
13
14
# File 'lib/semaph/shells/project/workflows_select_command.rb', line 10

def initialize(workflow_collection)
  @workflow_collection = workflow_collection
  @usage = "<workflow index>"
  @help = "choose workflow by index"
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



8
9
10
# File 'lib/semaph/shells/project/workflows_select_command.rb', line 8

def help
  @help
end

#usageObject (readonly)

Returns the value of attribute usage.



8
9
10
# File 'lib/semaph/shells/project/workflows_select_command.rb', line 8

def usage
  @usage
end

Instance Method Details

#execute(index_string) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/semaph/shells/project/workflows_select_command.rb', line 16

def execute(index_string)
  index = index_string.to_i - 1

  workflow = @workflow_collection.all[index]

  unless workflow
    puts "There is no workflow at position #{index}"
    return
  end

  ::Semaph::Shells::Workflow::WorkflowShell.new(workflow).push
end