Class: WIP::Runner::Shell::Handlers::Script

Inherits:
Base
  • Object
show all
Defined in:
lib/wip/runner/shell/handlers/script.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#type

Constructor Details

#initializeScript

Returns a new instance of Script.



11
12
13
14
15
16
# File 'lib/wip/runner/shell/handlers/script.rb', line 11

def initialize(*)
  @name    = 'script'
  @args    = []
  @prompts = []
  super
end

Instance Attribute Details

#promptsObject (readonly)

Returns the value of attribute prompts.



9
10
11
# File 'lib/wip/runner/shell/handlers/script.rb', line 9

def prompts
  @prompts
end

Instance Method Details

#args(array) ⇒ Object



35
36
37
# File 'lib/wip/runner/shell/handlers/script.rb', line 35

def args(array)
  @args = array
end

#description(format = :text) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/wip/runner/shell/handlers/script.rb', line 18

def description(format = :text)
  case format
  when :markdown
    "```\n#{@content}\n```"
  else
    @content
  end
end

#execute(io, env, &block) ⇒ Object



27
28
29
# File 'lib/wip/runner/shell/handlers/script.rb', line 27

def execute(io, env, &block)
  prompts.empty? ? simplex!(io, env, &block) : complex!(io, env, &block)
end

#name(value) ⇒ Object



31
32
33
# File 'lib/wip/runner/shell/handlers/script.rb', line 31

def name(value)
  @name = value
end

#prompt(term, options = {}) ⇒ Object



39
40
41
# File 'lib/wip/runner/shell/handlers/script.rb', line 39

def prompt(term, options = {})
  @prompts << [term, options] # Prompt.new(...)
end