Class: SpellCheck::Typo

Inherits:
Object
  • Object
show all
Defined in:
lib/spellcheck/typo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern: nil, expected: nil, line: nil, line_number: nil) ⇒ Typo

Returns a new instance of Typo.



5
6
7
8
9
10
# File 'lib/spellcheck/typo.rb', line 5

def initialize(pattern: nil, expected: nil, line: nil, line_number: nil)
  @pattern = pattern
  @expected = expected
  @line = line
  @line_number = line_number
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



3
4
5
# File 'lib/spellcheck/typo.rb', line 3

def expected
  @expected
end

#lineObject (readonly)

Returns the value of attribute line.



3
4
5
# File 'lib/spellcheck/typo.rb', line 3

def line
  @line
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



3
4
5
# File 'lib/spellcheck/typo.rb', line 3

def line_number
  @line_number
end

#patternObject (readonly)

Returns the value of attribute pattern.



3
4
5
# File 'lib/spellcheck/typo.rb', line 3

def pattern
  @pattern
end

Instance Method Details

#placeObject



12
13
14
15
16
# File 'lib/spellcheck/typo.rb', line 12

def place
  m = line.match(/(?<before>.{0,20})#{pattern}(?<after>.{0,20})/)

  [m[:before] || '', ColorString.red(pattern), m[:after] || ''].join
end