Module: PublicSuffixList::Parser
- Defined in:
- lib/public_suffix_list/parser.rb
Class Method Summary collapse
-
.parse(lines) ⇒ Object
{ “com” => => true, “jp” => { “tokyo” => => {:term => true, “*” => => true}, “hokkaido” => => {:term => true, “*” => => true}, “*” => => true } }.
Class Method Details
.parse(lines) ⇒ Object
"com" => {:term => true,
"jp" => {
"tokyo" => => {:term => true, "*" => => true},
"hokkaido" => => {:term => true, "*" => => true},
"*" => => true
}
}
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/public_suffix_list/parser.rb', line 21 def self.parse(lines) lines.inject({}) do |acc, line| line.strip! unless line =~ %r{//} or line.empty? tmp = acc line.split(".").reverse.each do |p| tmp[p] = {} unless tmp[p] tmp = tmp[p] end tmp[:term] = true end acc end end |