class EncoderTools::CLI::Base
Attributes
options[R]
shell[R]
Public Class Methods
new(shell, options={})
click to toggle source
# File lib/encoder-tools/cli/base.rb, line 6 def initialize(shell, options={}) @shell, @options = shell, options end
Private Class Methods
run(shell, options={})
click to toggle source
# File lib/encoder-tools/cli/base.rb, line 35 def self.run(shell, options={}) new(shell, options).run end
Public Instance Methods
run()
click to toggle source
# File lib/encoder-tools/cli/base.rb, line 10 def run # overridden in subclasses end
Private Instance Methods
input()
click to toggle source
# File lib/encoder-tools/cli/base.rb, line 15 def input @input ||= @options[:input] ? open(@options[:input]) : $stdin end
open(stream_or_file, mode='r')
click to toggle source
# File lib/encoder-tools/cli/base.rb, line 27 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
output()
click to toggle source
# File lib/encoder-tools/cli/base.rb, line 21 def output @output ||= @options[:output] ? open(@options[:output], 'w') : $stdout end