Class: Fog::Parsers::ProfitBricks::Base

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/fog/profitbricks/parsers/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



9
10
11
# File 'lib/fog/profitbricks/parsers/base.rb', line 9

def initialize
  reset
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/fog/profitbricks/parsers/base.rb', line 7

def response
  @response
end

Instance Method Details

#attr_value(name, attrs) ⇒ Object



13
14
15
# File 'lib/fog/profitbricks/parsers/base.rb', line 13

def attr_value(name, attrs)
  (entry = attrs.find {|a, v| a == name }) && entry.last
end

#characters(string) ⇒ Object



21
22
23
24
# File 'lib/fog/profitbricks/parsers/base.rb', line 21

def characters(string)
  @value ||= ''
  @value << string
end

#end_element_namespace(name, prefix = nil, uri = nil) ⇒ Object



33
34
35
# File 'lib/fog/profitbricks/parsers/base.rb', line 33

def end_element_namespace name, prefix = nil, uri = nil
  end_element name
end

#resetObject



17
18
19
# File 'lib/fog/profitbricks/parsers/base.rb', line 17

def reset
  @response = {}
end

#start_element(name, attrs = []) ⇒ Object

###############################################################################



39
40
41
# File 'lib/fog/profitbricks/parsers/base.rb', line 39

def start_element(name, attrs = [])
  @value = nil
end

#start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) ⇒ Object

############################################################################### This is a workaround. Original implementation from Nokogiri is overwritten with one that does not join namespace prefix with local name.



29
30
31
# File 'lib/fog/profitbricks/parsers/base.rb', line 29

def start_element_namespace name, attrs = [], prefix = nil, uri = nil, ns = []
  start_element name, attrs
end

#valueObject



43
44
45
# File 'lib/fog/profitbricks/parsers/base.rb', line 43

def value
  @value && @value.dup
end