Class: I18n::Tasks::Scanners::Results::Occurrence

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/tasks/scanners/results/occurrence.rb

Overview

Note:

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

The occurrence of some key in a file.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, pos:, line_num:, line_pos:, line:, raw_key: nil, default_arg: nil, candidate_keys: nil) ⇒ Occurrence

rubocop:disable Metrics/ParameterLists



42
43
44
45
46
47
48
49
50
51
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 42

def initialize(path:, pos:, line_num:, line_pos:, line:, raw_key: nil, default_arg: nil, candidate_keys: nil)
  @path = path
  @pos = pos
  @line_num = line_num
  @line_pos = line_pos
  @line = line
  @raw_key = raw_key
  @default_arg = default_arg
  @candidate_keys = candidate_keys
end

Instance Attribute Details

#candidate_keysArray<String>? (readonly)



32
33
34
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 32

def candidate_keys
  @candidate_keys
end

#default_argString? (readonly)



26
27
28
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 26

def default_arg
  @default_arg
end

#lineString (readonly)



23
24
25
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 23

def line
  @line
end

#line_numInteger (readonly)



17
18
19
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 17

def line_num
  @line_num
end

#line_posInteger (readonly)



20
21
22
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 20

def line_pos
  @line_pos
end

#pathString (readonly)



11
12
13
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 11

def path
  @path
end

#posInteger (readonly)



14
15
16
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 14

def pos
  @pos
end

#raw_keyString?



29
30
31
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 29

def raw_key
  @raw_key
end

Class Method Details

.from_range(raw_key:, range:, default_arg: nil) ⇒ Results::Occurrence



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 75

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

Instance Method Details

#==(other) ⇒ Object



58
59
60
61
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 58

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 && other.candidate_keys == @candidate_keys
end

#eql?(other) ⇒ Boolean



63
64
65
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 63

def eql?(other)
  self == other
end

#hashObject



67
68
69
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 67

def hash
  [@path, @pos, @line_num, @line_pos, @line, @default_arg, @candidate_keys].hash
end

#inspectObject

rubocop:enable Metrics/ParameterLists



54
55
56
# File 'lib/i18n/tasks/scanners/results/occurrence.rb', line 54

def inspect
  "Occurrence(#{@path}:#{@line_num}, line_pos: #{@line_pos}, pos: #{@pos}, raw_key: #{@raw_key}, candidate_keys: #{@candidate_keys}, default_arg: #{@default_arg}, line: #{@line})" # rubocop:disable Layout/LineLength
end