class Vindsl::PrefixMatcher
Public Class Methods
new(data)
click to toggle source
# File lib/vindsl/prefix_matcher.rb, line 3 def initialize(data) @data = data end
Public Instance Methods
all_prefixes(str)
click to toggle source
# File lib/vindsl/prefix_matcher.rb, line 11 def all_prefixes(str) str.length.times.map{|n| str[0..n]} end
find(prefix)
click to toggle source
# File lib/vindsl/prefix_matcher.rb, line 7 def find(prefix) @data[first_prefix prefix] end
first_prefix(prefix)
click to toggle source
# File lib/vindsl/prefix_matcher.rb, line 15 def first_prefix(prefix) all_prefixes(prefix).detect do |pfx| @data[pfx] end end