Class: String::Matchable::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/omu_support/core_ext/string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMatcher

Returns a new instance of Matcher.



68
69
70
# File 'lib/omu_support/core_ext/string.rb', line 68

def initialize
  @data = {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



66
67
68
# File 'lib/omu_support/core_ext/string.rb', line 66

def data
  @data
end

Instance Method Details

#match(language:, category:, word:) ⇒ Object



80
81
82
# File 'lib/omu_support/core_ext/string.rb', line 80

def match(language:, category:, word:)
  words(language, category).include? word
end

#run(languages:, category:, word:) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/omu_support/core_ext/string.rb', line 72

def run(languages:, category:, word:)
  (languages.empty? ? %w[en tr] : languages.uniq).each do |language|
    return true if match(language: language, category: category, word: word)
  end

  false
end