Class: Forspell::Loaders::Base
- Inherits:
-
Object
- Object
- Forspell::Loaders::Base
- Defined in:
- lib/forspell/loaders/base.rb
Instance Method Summary collapse
-
#initialize(file: nil, text: nil) ⇒ Base
constructor
A new instance of Base.
- #read ⇒ Object
Constructor Details
#initialize(file: nil, text: nil) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 |
# File 'lib/forspell/loaders/base.rb', line 12 def initialize(file: nil, text: nil) @file = file @input = text || input @words = [] @errors = [] end |
Instance Method Details
#read ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/forspell/loaders/base.rb', line 19 def read extract_words.each { |word| word.text = Forspell::Sanitizer.sanitize(word.text) } .select{ |word| Forspell::WordMatcher.word?(word.text) } .reject { |w| w.text.nil? || w.text.empty? } rescue YARD::Parser::ParserSyntaxError, RuntimeError => e raise Forspell::Loaders::ParsingError, e. end |