class Veezi::API::Parser
Public Class Methods
new(content_type = nil)
click to toggle source
# File lib/veezi/api/parser.rb, line 6 def initialize(content_type = nil) @content_type = content_type || :json end
Public Instance Methods
parse(content)
click to toggle source
# File lib/veezi/api/parser.rb, line 10 def parse(content) case @content_type.to_sym when :xml hash = Crack::XML.parse(content) if key = hash.keys.find { |key| key =~ /ArrayOf/ } hash.fetch(key, {}).delete_if { |k,v| k.include?("xml") }.values.flatten else hash.values.first || {} end else Crack::JSON.parse(content) end end