class Ripgrep::Result
Attributes
exit_status[R]
matches[R]
raw_error[R]
raw_result[R]
Public Class Methods
new(result, error = '', exit_status: 0)
click to toggle source
# File lib/ripgrep/result.rb, line 11 def initialize(result, error = '', exit_status: 0) @raw_result = result @raw_error = error @exit_status = exit_status # TODO: skip when not matching result. like a help or version. # $ rg --files で対象ファイルが取れるので、これと比較してmatch結果かどうか見るのがいいかも @matches = result.split("\n").map do |line| file, *body = line.split(':') Match.new file: file, body: body.join(':'), raw_line: line end case exit_status when Status::SUCCESS when Status::NO_MATCH when Status::ERROR raise Ripgrep::ResultError, error else raise Ripgrep::ResultError, error end end
Public Instance Methods
lines()
click to toggle source
# File lib/ripgrep/result.rb, line 33 def lines @raw_result.to_s.split("\n") end
Also aliased as: to_a
to_s()
click to toggle source
# File lib/ripgrep/result.rb, line 38 def to_s @raw_result.to_s end