class I18n::Processes::Scanners::Results::Occurrence

The occurrence of some key in a file.

@note This is a value type. Equality and hash code are determined from the attributes.

Attributes

default_arg[R]

@return [String, nil] the value of the `default:` argument of the translate call.

line[R]

@return [String] the line of the occurrence, excluding the last LF or CRLF.

line_num[R]

@return [Integer] line number of the occurrence, counting from 1.

line_pos[R]

@return [Integer] position of the start of the occurrence in the line, counting from 1.

path[R]

@return [String] source path relative to the current working directory.

pos[R]

@return [Integer] count of characters in the file before the occurrence.

raw_key[RW]

@return [String, nil] the raw key (for relative keys and references)

Public Class Methods

new(path:, pos:, line_num:, line_pos:, line:, raw_key: nil, default_arg: nil) click to toggle source

@param path [String] @param pos [Integer] @param line_num [Integer] @param line_pos [Integer] @param line [String] @param raw_key [String, nil] @param default_arg [String, nil] rubocop:disable Metrics/ParameterLists

# File lib/i18n/processes/scanners/results/occurrence.rb, line 39
def initialize(path:, pos:, line_num:, line_pos:, line:, raw_key: nil, default_arg: nil)
  @path        = path
  @pos         = pos
  @line_num    = line_num
  @line_pos    = line_pos
  @line        = line
  @raw_key     = raw_key
  @default_arg = default_arg
end

Public Instance Methods

==(other) click to toggle source
# File lib/i18n/processes/scanners/results/occurrence.rb, line 54
def ==(other)
  other.path == @path && other.pos == @pos && other.line_num == @line_num && other.line == @line &&
    other.raw_key == @raw_key && other.default_arg == @default_arg
end
eql?(other) click to toggle source
# File lib/i18n/processes/scanners/results/occurrence.rb, line 59
def eql?(other)
  self == other
end
hash() click to toggle source
# File lib/i18n/processes/scanners/results/occurrence.rb, line 63
def hash
  [@path, @pos, @line_num, @line_pos, @line, @default_arg].hash
end
inspect() click to toggle source

rubocop:enable Metrics/ParameterLists

# File lib/i18n/processes/scanners/results/occurrence.rb, line 50
def inspect
  "Occurrence(#{@path}:#{@line_num}:#{@line_pos}:#{@pos}:#{@raw_key}:#{@default_arg})"
end