Sha256: ff2d189fb616bda9d9d4bd38b185b1d53bd16ae4b7b498431260d8d8129444a3
Contents?: true
Size: 815 Bytes
Versions: 2
Compression:
Stored size: 815 Bytes
Contents
module EncoderTools class CLI class Base attr_reader :shell, :options def initialize(shell, options={}) @shell, @options = shell, options end def run # overridden in subclasses end private def input @input ||= @options[:input] ? open(@options[:input]) : $stdin end def output @output ||= @options[:output] ? open(@options[:output], 'w') : $stdout end def open(stream_or_file, mode='r') if stream_or_file.respond_to?(:eof?) stream_or_file else File.open(stream_or_file, mode) end end def self.run(shell, options={}) new(shell, options).run end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
encoder-tools-1.0.0 | lib/encoder-tools/cli/base.rb |
encoder-tools-0.0.2 | lib/encoder-tools/cli/base.rb |