Class: PullRequestAi::Repo::File
- Inherits:
-
Object
- Object
- PullRequestAi::Repo::File
- Defined in:
- lib/pull_request_ai/repo/file.rb
Instance Attribute Summary collapse
-
#modified_lines ⇒ Object
readonly
Returns the value of attribute modified_lines.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, modified_lines) ⇒ File
constructor
A new instance of File.
- #trimmed_modified_lines ⇒ Object
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_lines ⇒ Object (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 |
#name ⇒ Object (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_lines ⇒ Object
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 |