class PmdFile

Represent a PMD file.

Attributes

absolute_path[R]

An absolute path to this file

@return [String]

file[RW]
relative_path[R]

A relative path to this file

@return [String]

Public Class Methods

new(prefix, file) click to toggle source
# 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

Public Instance Methods

violations() click to toggle source
# 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

Private Instance Methods

file_separator() click to toggle source
# File lib/pmd/entity/pmd_file.rb, line 39
def file_separator
  File::ALT_SEPARATOR || File::SEPARATOR
end