Module: IndeStruct::Parser

Extended by:
Parser
Included in:
Parser
Defined in:
lib/inde_struct/parser.rb,
lib/inde_struct/parser/hash_any_case.rb,
lib/inde_struct/parser/open_struct_any_case.rb

Defined Under Namespace

Classes: HashAnyCase, OpenStructAnyCase

Instance Method Summary collapse

Instance Method Details

#parse(obj) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/inde_struct/parser.rb', line 7

def parse(obj)
  return case obj
  when Hash
    obj = obj.clone
    obj.each do |k,v|
      obj[k] = self.parse(v)
    end
    IndeStruct::Parser::OpenStructAnyCase.new(obj)
  when Array
    obj = obj.clone
    obj.map! {|i| self.parse(i)}
  else
    obj
  end
end