Class: Misspelling

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

Overview

Parse, model, and print a misspelling

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, word, line, column, suggestions) ⇒ Misspelling

Returns a new instance of Misspelling.



69
70
71
72
73
74
75
# File 'lib/aspelllint.rb', line 69

def initialize(filename, word, line, column, suggestions)
  @filename = filename
  @word = word
  @line = line
  @column = column
  @suggestions = suggestions
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



56
57
58
# File 'lib/aspelllint.rb', line 56

def column
  @column
end

#filenameObject

Returns the value of attribute filename.



56
57
58
# File 'lib/aspelllint.rb', line 56

def filename
  @filename
end

#lineObject

Returns the value of attribute line.



56
57
58
# File 'lib/aspelllint.rb', line 56

def line
  @line
end

#suggestionsObject

Returns the value of attribute suggestions.



56
57
58
# File 'lib/aspelllint.rb', line 56

def suggestions
  @suggestions
end

#wordObject

Returns the value of attribute word.



56
57
58
# File 'lib/aspelllint.rb', line 56

def word
  @word
end

Class Method Details

.parse(filename, aspell_line) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/aspelllint.rb', line 58

def self.parse(filename, aspell_line)
  match = aspell_line.match(/^\&\s(.+)\s([0-9]+)\s([0-9]+)\:\s(.+)$/)

  w = match[1]
  l = match[2]
  c = match[3]
  s = match[4]

  Misspelling.new(filename, w, l, c, s)
end

Instance Method Details

#to_sObject



77
78
79
# File 'lib/aspelllint.rb', line 77

def to_s
  "#{filename}:#{line}:#{column} #{word}: #{suggestions}"
end