Module: Word::Match

Includes:
Regexp
Defined in:
lib/word/match.rb

Instance Method Summary collapse

Methods included from Regexp

has_any_regexp, #word_regexp

Instance Method Details

#has_all?(*args) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/word/match.rb', line 16

def has_all?(*args)
  words = args.first.respond_to?("-") ? args.first : args
  matching = match(Regexp.has_any_regexp(words)).to_s.downcase
  return false if matching.empty?
  remain = words - [matching]
  if remain.empty?
    true
  else
    has_all?(remain)
  end
end

#has_any?(*args) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/word/match.rb', line 11

def has_any?(*args)
  words = args.first.respond_to?("-") ? args.first : args
  return nil != (self =~ Regexp.has_any_regexp(words))
end

#has_none?(*args) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/word/match.rb', line 6

def has_none?(*args)
  words = args.first.respond_to?("-") ? args.first : args
  return nil == (self =~ Regexp.has_any_regexp(words))
end