Class: Fog::Parsers::Schema::NodeStack

Inherits:
Array
  • Object
show all
Defined in:
lib/ext_fog_aws/fog/parsers/schema.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ NodeStack

Returns a new instance of NodeStack.



29
30
31
32
# File 'lib/ext_fog_aws/fog/parsers/schema.rb', line 29

def initialize(*args)
  @response, @schema, @arrays = args
  super()
end

Instance Method Details

#end_element(name, value) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/ext_fog_aws/fog/parsers/schema.rb', line 46

def end_element(name, value)
  if top
    if (@arrays + [top.name]).include? name
      top.update_result(value)
      pop
    end
  end
end

#new_node(name, schema_pointer, result_pointer) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ext_fog_aws/fog/parsers/schema.rb', line 55

def new_node(name, schema_pointer, result_pointer)
  node_class =
    case schema_pointer[name]
    when Hash
      NodeHash
    when Array
      NodeArray
    else
      NodeValue
    end
  node_class.new(name, schema_pointer, result_pointer)
end

#start_element(name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ext_fog_aws/fog/parsers/schema.rb', line 34

def start_element(name)
  if top
    if @arrays.include? name
      push top.new_item
    elsif top.next_schema.key? name
      push new_node(name, top.next_schema, top.next_result)
    end
  elsif @schema.key? name
    push new_node(name, @schema, @response)
  end
end