class SelectObject

Special class to select a string via Regex. Needed for flexible search for MAC, firmware-name and so on. Helper to construct a Regex.

Public Class Methods

new(var) click to toggle source

Helper

# File lib/hodmin/hodmin_tools.rb, line 368
def initialize(var)
  @regex = self.class.string_to_regex(var)
end
string_to_regex(var) click to toggle source
# File lib/hodmin/hodmin_tools.rb, line 363
def self.string_to_regex(var)
  Regexp.new "^#{Regexp.escape(var).gsub('\*', '.*?')}$"
end

Public Instance Methods

=~(other) click to toggle source

Helper

# File lib/hodmin/hodmin_tools.rb, line 373
def =~(other)
  !!(other =~ @regex)
end