Class: RubyLint::Report::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-lint/report/entry.rb

Overview

Entry contains data about a single report entry such as the message and line number.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Entry

Returns a new instance of Entry

Parameters:

  • attributes (Hash) (defaults to: {})


31
32
33
34
35
# File 'lib/ruby-lint/report/entry.rb', line 31

def initialize(attributes = {})
  attributes.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#columnNumeric (readonly)

Returns:

  • (Numeric)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby-lint/report/entry.rb', line 25

class Entry
  attr_reader :level, :message, :line, :column, :file, :node

  ##
  # @param [Hash] attributes
  #
  def initialize(attributes = {})
    attributes.each do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end

  ##
  # @return [String]
  #
  def filename
    return File.basename(file)
  end

  ##
  # Returns a Hash containing the attributes of the entry.
  #
  # @return [Hash]
  #
  def attributes
    return {
      :level    => level,
      :message  => message,
      :line     => line,
      :column   => column,
      :file     => file,
      :filename => filename,
      :node     => node
    }
  end

  ##
  # Determines the sort order of the current entry. The entry is sorted
  # based on the filename and the line.
  #
  # @param [RubyLint::Report::Entry] other The entry to compare with the
  #  current one.
  # @return [Numeric]
  #
  def <=>(other)
    [file, line, column] <=> [other.file, other.line, other.column]
  end
end

#fileString (readonly)

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby-lint/report/entry.rb', line 25

class Entry
  attr_reader :level, :message, :line, :column, :file, :node

  ##
  # @param [Hash] attributes
  #
  def initialize(attributes = {})
    attributes.each do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end

  ##
  # @return [String]
  #
  def filename
    return File.basename(file)
  end

  ##
  # Returns a Hash containing the attributes of the entry.
  #
  # @return [Hash]
  #
  def attributes
    return {
      :level    => level,
      :message  => message,
      :line     => line,
      :column   => column,
      :file     => file,
      :filename => filename,
      :node     => node
    }
  end

  ##
  # Determines the sort order of the current entry. The entry is sorted
  # based on the filename and the line.
  #
  # @param [RubyLint::Report::Entry] other The entry to compare with the
  #  current one.
  # @return [Numeric]
  #
  def <=>(other)
    [file, line, column] <=> [other.file, other.line, other.column]
  end
end

#levelSymbol (readonly)

Returns:

  • (Symbol)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby-lint/report/entry.rb', line 25

class Entry
  attr_reader :level, :message, :line, :column, :file, :node

  ##
  # @param [Hash] attributes
  #
  def initialize(attributes = {})
    attributes.each do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end

  ##
  # @return [String]
  #
  def filename
    return File.basename(file)
  end

  ##
  # Returns a Hash containing the attributes of the entry.
  #
  # @return [Hash]
  #
  def attributes
    return {
      :level    => level,
      :message  => message,
      :line     => line,
      :column   => column,
      :file     => file,
      :filename => filename,
      :node     => node
    }
  end

  ##
  # Determines the sort order of the current entry. The entry is sorted
  # based on the filename and the line.
  #
  # @param [RubyLint::Report::Entry] other The entry to compare with the
  #  current one.
  # @return [Numeric]
  #
  def <=>(other)
    [file, line, column] <=> [other.file, other.line, other.column]
  end
end

#lineNumeric (readonly)

Returns:

  • (Numeric)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby-lint/report/entry.rb', line 25

class Entry
  attr_reader :level, :message, :line, :column, :file, :node

  ##
  # @param [Hash] attributes
  #
  def initialize(attributes = {})
    attributes.each do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end

  ##
  # @return [String]
  #
  def filename
    return File.basename(file)
  end

  ##
  # Returns a Hash containing the attributes of the entry.
  #
  # @return [Hash]
  #
  def attributes
    return {
      :level    => level,
      :message  => message,
      :line     => line,
      :column   => column,
      :file     => file,
      :filename => filename,
      :node     => node
    }
  end

  ##
  # Determines the sort order of the current entry. The entry is sorted
  # based on the filename and the line.
  #
  # @param [RubyLint::Report::Entry] other The entry to compare with the
  #  current one.
  # @return [Numeric]
  #
  def <=>(other)
    [file, line, column] <=> [other.file, other.line, other.column]
  end
end

#messageString (readonly)

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby-lint/report/entry.rb', line 25

class Entry
  attr_reader :level, :message, :line, :column, :file, :node

  ##
  # @param [Hash] attributes
  #
  def initialize(attributes = {})
    attributes.each do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end

  ##
  # @return [String]
  #
  def filename
    return File.basename(file)
  end

  ##
  # Returns a Hash containing the attributes of the entry.
  #
  # @return [Hash]
  #
  def attributes
    return {
      :level    => level,
      :message  => message,
      :line     => line,
      :column   => column,
      :file     => file,
      :filename => filename,
      :node     => node
    }
  end

  ##
  # Determines the sort order of the current entry. The entry is sorted
  # based on the filename and the line.
  #
  # @param [RubyLint::Report::Entry] other The entry to compare with the
  #  current one.
  # @return [Numeric]
  #
  def <=>(other)
    [file, line, column] <=> [other.file, other.line, other.column]
  end
end

#nodeRubyLint::AST::Node (readonly)

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby-lint/report/entry.rb', line 25

class Entry
  attr_reader :level, :message, :line, :column, :file, :node

  ##
  # @param [Hash] attributes
  #
  def initialize(attributes = {})
    attributes.each do |key, value|
      instance_variable_set("@#{key}", value)
    end
  end

  ##
  # @return [String]
  #
  def filename
    return File.basename(file)
  end

  ##
  # Returns a Hash containing the attributes of the entry.
  #
  # @return [Hash]
  #
  def attributes
    return {
      :level    => level,
      :message  => message,
      :line     => line,
      :column   => column,
      :file     => file,
      :filename => filename,
      :node     => node
    }
  end

  ##
  # Determines the sort order of the current entry. The entry is sorted
  # based on the filename and the line.
  #
  # @param [RubyLint::Report::Entry] other The entry to compare with the
  #  current one.
  # @return [Numeric]
  #
  def <=>(other)
    [file, line, column] <=> [other.file, other.line, other.column]
  end
end

Instance Method Details

#<=>(other) ⇒ Numeric

Determines the sort order of the current entry. The entry is sorted based on the filename and the line.

Parameters:

Returns:

  • (Numeric)


69
70
71
# File 'lib/ruby-lint/report/entry.rb', line 69

def <=>(other)
  [file, line, column] <=> [other.file, other.line, other.column]
end

#attributesHash

Returns a Hash containing the attributes of the entry.

Returns:

  • (Hash)


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ruby-lint/report/entry.rb', line 49

def attributes
  return {
    :level    => level,
    :message  => message,
    :line     => line,
    :column   => column,
    :file     => file,
    :filename => filename,
    :node     => node
  }
end

#filenameString

Returns:



40
41
42
# File 'lib/ruby-lint/report/entry.rb', line 40

def filename
  return File.basename(file)
end