Class: PullRequestAi::Repo::File

Inherits:
Object
  • Object
show all
Defined in:
lib/pull_request_ai/repo/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, modified_lines) ⇒ File

Returns a new instance of File.



8
9
10
11
# File 'lib/pull_request_ai/repo/file.rb', line 8

def initialize(name, modified_lines)
  @name = name
  @modified_lines = modified_lines
end

Instance Attribute Details

#modified_linesObject (readonly)

Returns the value of attribute modified_lines.



6
7
8
# File 'lib/pull_request_ai/repo/file.rb', line 6

def modified_lines
  @modified_lines
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/pull_request_ai/repo/file.rb', line 6

def name
  @name
end

Instance Method Details

#trimmed_modified_linesObject



13
14
15
16
17
# File 'lib/pull_request_ai/repo/file.rb', line 13

def trimmed_modified_lines
  modified_lines.inject(name + "\n") do |result, line|
    result << line.sub(/([+\-])\s*/) { ::Regexp.last_match(1) } + "\n"
  end
end