Class: PmdFile
- Inherits:
-
Object
- Object
- PmdFile
- Defined in:
- lib/pmd/entity/pmd_file.rb
Overview
Represent a PMD file.
Instance Attribute Summary collapse
-
#absolute_path ⇒ String
readonly
An absolute path to this file.
-
#file ⇒ Object
Returns the value of attribute file.
-
#relative_path ⇒ String
readonly
A relative path to this file.
Instance Method Summary collapse
-
#initialize(prefix, file) ⇒ PmdFile
constructor
A new instance of PmdFile.
- #violations ⇒ Object
Constructor Details
#initialize(prefix, file) ⇒ PmdFile
Returns a new instance of PmdFile.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pmd/entity/pmd_file.rb', line 19 def initialize(prefix, file) @file = file @absolute_path = file.attribute('name').value.to_s prefix += (prefix.end_with?(file_separator) ? '' : file_separator) @relative_path = if @absolute_path.start_with?(prefix) @absolute_path[prefix.length, @absolute_path.length - prefix.length] else @absolute_path end end |
Instance Attribute Details
#absolute_path ⇒ String (readonly)
An absolute path to this file
12 13 14 |
# File 'lib/pmd/entity/pmd_file.rb', line 12 def absolute_path @absolute_path end |
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/pmd/entity/pmd_file.rb', line 7 def file @file end |
#relative_path ⇒ String (readonly)
A relative path to this file
17 18 19 |
# File 'lib/pmd/entity/pmd_file.rb', line 17 def relative_path @relative_path end |
Instance Method Details
#violations ⇒ Object
31 32 33 34 35 |
# File 'lib/pmd/entity/pmd_file.rb', line 31 def violations @violations ||= file.xpath('violation').map do |pmd_violation| PmdViolation.new(pmd_violation) end end |