Class: String::Matchable::Matcher
- Defined in:
- lib/omu_support/core_ext/string.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize ⇒ Matcher
constructor
A new instance of Matcher.
- #match(language:, category:, word:) ⇒ Object
- #run(languages:, category:, word:) ⇒ Object
Constructor Details
#initialize ⇒ Matcher
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
#data ⇒ Object (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 |