Class: WIP::Runner::Shell::Handlers::Base
- Inherits:
-
Object
- Object
- WIP::Runner::Shell::Handlers::Base
- Defined in:
- lib/wip/runner/shell/handlers/base.rb
Instance Method Summary collapse
- #content(format = :text) ⇒ Object
- #execute(io, env, &block) ⇒ Object
-
#initialize(content, &block) ⇒ Base
constructor
A new instance of Base.
- #output ⇒ Object
- #type ⇒ Object
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
23 24 25 |
# File 'lib/wip/runner/shell/handlers/base.rb', line 23 def execute(io, env, &block) raise NotImplementedError end |
#output ⇒ Object
27 28 29 |
# File 'lib/wip/runner/shell/handlers/base.rb', line 27 def output @output.string end |
#type ⇒ Object
31 32 33 |
# File 'lib/wip/runner/shell/handlers/base.rb', line 31 def type @type ||= self.class.name.split('::').last end |