Class: SpellCheck::Typo
- Inherits:
-
Object
- Object
- SpellCheck::Typo
- Defined in:
- lib/spellcheck/typo.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern: nil, expected: nil, line: nil, line_number: nil) ⇒ Typo
constructor
A new instance of Typo.
- #place ⇒ Object
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
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
3 4 5 |
# File 'lib/spellcheck/typo.rb', line 3 def expected @expected end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/spellcheck/typo.rb', line 3 def line @line end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
3 4 5 |
# File 'lib/spellcheck/typo.rb', line 3 def line_number @line_number end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
3 4 5 |
# File 'lib/spellcheck/typo.rb', line 3 def pattern @pattern end |
Instance Method Details
#place ⇒ Object
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 |