Sha256: 0981a018c39282f3209b6d2018799afbaeabaaa42271162d5f4eac18c1a55953

Contents?: true

Size: 614 Bytes

Versions: 1

Compression:

Stored size: 614 Bytes

Contents

require "open3"

class Rbsh::Shell < BasicObject
  attr_writer :_queue
  attr_accessor :_result

  def run!
    @_result = [] unless @_result
    _queue.each do |pipeline|
      @_result += pipeline.to_ary
    end
    to_s
  end

  def to_ary
    _result
  end

  def to_s
    to_ary.join("")
  end
  alias inspect to_s

  def method_missing(name, *args, &block)
    pipeline = ::Rbsh::Pipeline.new(name, *args)
    _queue.push(pipeline)
    pipeline
  end

  def load_script!(script)
    instance_eval(script)
  end

  protected

  def _queue
    @_queue ||= []
  end

  def _result
    @_result ||= []
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbsh-0.0.1 lib/rbsh/shell.rb