Class: Array

Inherits:
Object show all
Defined in:
lib/cuboid/ruby/array.rb

Instance Method Summary collapse

Instance Method Details

#includes_tags?(tags) ⇒ Bool

Returns ‘true` if `self` contains any of the `tags` when objects of both `self` and `tags` are converted to `String`.

Parameters:

  • tags (#to_s, Array<#to_s>)

Returns:

  • (Bool)

    ‘true` if `self` contains any of the `tags` when objects of both `self` and `tags` are converted to `String`.



8
9
10
11
12
13
14
15
# File 'lib/cuboid/ruby/array.rb', line 8

def includes_tags?( tags )
    return false if !tags

    tags = [tags].flatten.compact.map( &:to_s )
    return false if tags.empty?

    (self.flatten.compact.map( &:to_s ) & tags).any?
end