Class: Matchers::IPMatcher
Instance Attribute Summary collapse
-
#trie ⇒ Object
readonly
Returns the value of attribute trie.
Instance Method Summary collapse
-
#initialize(patterns) ⇒ IPMatcher
constructor
A new instance of IPMatcher.
- #matches?(text) ⇒ Boolean
Constructor Details
Instance Attribute Details
#trie ⇒ Object (readonly)
Returns the value of attribute trie.
25 26 27 |
# File 'lib/matcher.rb', line 25 def trie @trie end |
Instance Method Details
#matches?(text) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/matcher.rb', line 33 def matches?(text) return false if text.nil? ip = IPAddr.new(text).to_i.to_s(2).rjust(32, '0') trie.forward_match(ip) end |