Class: ClosingComments::Source
- Inherits:
-
Object
- Object
- ClosingComments::Source
- Extended by:
- Forwardable
- Defined in:
- lib/closing_comments/source.rb
Defined Under Namespace
Classes: Problem
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #fix ⇒ Object
-
#initialize(path:, content:) ⇒ Source
constructor
A new instance of Source.
- #problematic? ⇒ Boolean
- #problems ⇒ Object
Constructor Details
#initialize(path:, content:) ⇒ Source
Returns a new instance of Source.
15 16 17 18 |
# File 'lib/closing_comments/source.rb', line 15 def initialize(path:, content:) @path = path @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/closing_comments/source.rb', line 8 def content @content end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/closing_comments/source.rb', line 8 def path @path end |
Class Method Details
.from(path:) ⇒ Object
11 12 13 |
# File 'lib/closing_comments/source.rb', line 11 def self.from(path:) new(path: path, content: File.read(path)) end |
Instance Method Details
#fix ⇒ Object
32 33 34 |
# File 'lib/closing_comments/source.rb', line 32 def fix lines.map.with_index(1) { |default, no| fixes[no] || default }.join("\n") end |
#problematic? ⇒ Boolean
20 21 22 |
# File 'lib/closing_comments/source.rb', line 20 def problematic? problems.count.positive? end |