lib/ryodo/rule_set.rb in ryodo-0.2.2 vs lib/ryodo/rule_set.rb in ryodo-0.2.4.1

- old
+ new

@@ -1,6 +1,6 @@ -# encoding: utf-8 +# coding: utf-8 module Ryodo class RuleSet def initialize @@ -33,22 +33,16 @@ end end def select_rule(rule_path) - path = rule_path.dup - - if current = path.pop - - if path.empty? - @tree[current] - + if rule_path[-1] + if rule_path[0..-2].empty? + @tree[rule_path[-1]] else - rule = select_rule(path) - rule.children[current] if rule + rule = select_rule(rule_path[0..-2]) and rule.children[rule_path[-1]] end - end end def match(path) suffix, domain, match = [], [], nil @@ -67,6 +61,6 @@ [ suffix, [domain.shift], domain ] end end end -end \ No newline at end of file +end