class WorkingSetItem

Attributes

column[RW]
file_path[RW]
match_line[RW]
pinned[RW]
post_match_lines[RW]
pre_match_lines[RW]
row[RW]

Public Class Methods

new(props = {}) click to toggle source
# File lib/working_set_item.rb, line 4
def initialize(props = {})
  self.file_path        = props[:file_path]
  self.row              = (props[:row]             || 0).to_i
  self.column           = (props[:column]          || 0).to_i
  self.pre_match_lines  = props[:pre_match_lines]  || []
  self.match_line       = props[:match_line]       || ""
  self.post_match_lines = props[:post_match_lines] || []
  self.pinned           = !!props[:pinned]
end

Public Instance Methods

==(other) click to toggle source
# File lib/working_set_item.rb, line 28
def ==(other)
  other &&
    file_path == other.file_path &&
    row == other.row &&
    column == other.column &&
    match_line == other.match_line
end
full_body() click to toggle source
# File lib/working_set_item.rb, line 36
def full_body
  (pre_match_lines + [match_line] + post_match_lines).join("\n")
end
inspect() click to toggle source
# File lib/working_set_item.rb, line 14
def inspect
  str = "#{file_path}\n"
  pre_match_lines.each_with_index do |line, idx|
    str += "#{row - pre_match_lines.size + idx}- #{line}\n"
  end
  str += "#{row}: #{match_line}\n"
  offset = column + row.to_s.length + 1
  str += sprintf "%#{offset}s%s", " ", "^\n"
  post_match_lines.each_with_index do |line, idx|
    str += "#{row + 1 + idx}- #{line}\n"
  end
  str
end