class Browserino::Matcher
Constants
- SETTINGS
Attributes
pattern[R]
properties[R]
Public Class Methods
new(pattern = //, opts = {}, **additional, &block)
click to toggle source
# File lib/browserino/matcher.rb, line 9 def initialize(pattern = //, opts = {}, **additional, &block) opts = pattern if pattern.is_a?(Hash) && opts.empty? @properties = SETTINGS.merge(opts.merge(additional)) @pattern = pattern instance_eval(&block) if block end
Public Instance Methods
==(other)
click to toggle source
# File lib/browserino/matcher.rb, line 41 def ==(other) self === other end
===(other)
click to toggle source
# File lib/browserino/matcher.rb, line 25 def ===(other) return false unless (name = properties[:name]) case other when Regexp then other =~ name when String then other.to_sym == name when Symbol then other == name when Matcher then other.name == name else false end end
=~(other)
click to toggle source
# File lib/browserino/matcher.rb, line 21 def =~(other) pattern =~ other end
matches?(user_agent)
click to toggle source
# File lib/browserino/matcher.rb, line 17 def matches?(user_agent) pattern =~ user_agent end
method_missing(sym, *args, &block)
click to toggle source
# File lib/browserino/matcher.rb, line 45 def method_missing(sym, *args, &block) return @properties[sym] = args.shift if args.any? return @properties[sym] = block if block @properties[sym] end
respond_to_missing?(*)
click to toggle source
# File lib/browserino/matcher.rb, line 52 def respond_to_missing?(*) true end
to_str()
click to toggle source
# File lib/browserino/matcher.rb, line 37 def to_str properties[:name].to_s end