Class: WIP::Runner::Shell::Handlers::Base

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

Direct Known Subclasses

Script, System

Instance Method Summary collapse

Constructor Details

#initialize(content, &block) ⇒ Base

Returns a new instance of Base.



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

def initialize(content, &block)
  @content = clean(content)
  @output  = StringIO.new
  instance_exec(&block) if block_given?
end

Instance Method Details

#content(format = :text) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/wip/runner/shell/handlers/base.rb', line 14

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

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

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/wip/runner/shell/handlers/base.rb', line 23

def execute(io, env, &block)
  raise NotImplementedError
end

#outputObject



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

def output
  @output.string
end

#typeObject



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

def type
  @type ||= self.class.name.split('::').last
end