Module: JQuery

Defined in:
lib/merger.rb

Defined Under Namespace

Classes: Method, Methods, Parser

Class Method Summary collapse

Class Method Details

.convert(a) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/merger.rb', line 3

def self.convert(a)
  h = {}
  a.each do |s|
    parse_into(h, s)
  end
  h
end

.parse_into(frob, s) ⇒ Object



11
12
13
# File 'lib/merger.rb', line 11

def self.parse_into(frob, s)
  s.split("/").each { |s1| frob = (frob[s1] ||= {}) }
end


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/merger.rb', line 15

def self.print_tree(hsh, c = 0)
  hsh.each do |k,v|
    puts k
    if c > 0
      print "|#{'-' * c}"
    end
    if v != {}
      self.print_tree(v, c + 1)
    end
  end
end