class I18n::Tasks::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
@return [String, nil] the value of the ‘default:` argument of the translate call.
@return [String] the line of the occurrence, excluding the last LF or CRLF.
@return [Integer] line number of the occurrence, counting from 1.
@return [Integer] position of the start of the occurrence in the line, counting from 1.
@return [String] source path relative to the current working directory.
@return [Integer] count of characters in the file before the occurrence.
@return [String, nil] the raw key (for relative keys and references)
Public Class Methods
Source
# File lib/i18n/tasks/scanners/results/occurrence.rb, line 71 def self.from_range(raw_key:, range:, default_arg: nil) Occurrence.new( path: range.source_buffer.name, pos: range.begin_pos, line_num: range.line, line_pos: range.column, line: range.source_line, raw_key: raw_key, default_arg: default_arg ) end
@param raw_key
[String] @param range [Parser::Source::Range] @param default_arg
[String, nil] @return [Results::Occurrence]
Source
# File lib/i18n/tasks/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
@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
Public Instance Methods
Source
# File lib/i18n/tasks/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
Source
# File lib/i18n/tasks/scanners/results/occurrence.rb, line 59 def eql?(other) self == other end
Source
# File lib/i18n/tasks/scanners/results/occurrence.rb, line 63 def hash [@path, @pos, @line_num, @line_pos, @line, @default_arg].hash end
Source
# File lib/i18n/tasks/scanners/results/occurrence.rb, line 50 def inspect "Occurrence(#{@path}:#{@line_num}, line_pos: #{@line_pos}, pos: #{@pos}, raw_key: #{@raw_key}, default_arg: #{@default_arg}, line: #{@line})" # rubocop:disable Layout/LineLength end
rubocop:enable Metrics/ParameterLists