Class: Smyte::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/smyte/util.rb

Class Method Summary collapse

Class Method Details

.label_interesting?(name, options) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/smyte/util.rb', line 4

def label_interesting?(name, options)
  return true unless options
  return true unless options[:labels]
  return true if options[:labels].empty?

  pieces = name.split(":")

  options[:labels].each do |check|
    if check.is_a?(String)
      return true if name == check
      return true if pieces.last == check
    elsif check.is_a?(Regexp)
      return true if name =~ check
      return true if pieces.last =~ check
    end
  end

  return false
end