class RubyEdit::Grep
Attributes
result[R]
Public Class Methods
new(options)
click to toggle source
# File lib/ruby_edit/grep.rb, line 9 def initialize(options) @path = options[:path] || '*' @expression = options[:expression] @config = RubyEdit.config end
Public Instance Methods
search(output: $stdout, errors: $stderr)
click to toggle source
# File lib/ruby_edit/grep.rb, line 15 def search(output: $stdout, errors: $stderr) if empty_expression? output.puts 'No expression given' return false end @result = run "grep -#{@config.grep_options} #{@path} -e '#{@expression}'" do |out, err| errors << err if err end rescue TTY::Command::ExitError => error output.puts error end
Private Instance Methods
empty_expression?()
click to toggle source
# File lib/ruby_edit/grep.rb, line 29 def empty_expression? @expression.nil? || @expression.empty? end