Class: Smartdict::Translator::LanguageDetector::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/smartdict/translator/language_detector.rb

Instance Method Summary collapse

Constructor Details

#initialize(chars) ⇒ Matcher

Returns a new instance of Matcher.



61
62
63
# File 'lib/smartdict/translator/language_detector.rb', line 61

def initialize(chars)
  @chars = chars + [" ", "-"]
end

Instance Method Details

#match?(word) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
# File 'lib/smartdict/translator/language_detector.rb', line 65

def match?(word)
  word.each_char do |char|
    return false unless @chars.include? char
  end
  true
end