class GoogleAppsOauth2::Atom::Document
Public Class Methods
new(doc, map = {})
click to toggle source
# File lib/google_apps_oauth2/atom/document.rb, line 6 def initialize(doc, map = {}) @doc = parse(doc) @map = map end
Public Instance Methods
find_values()
click to toggle source
find_values
searches @doc and assigns any values to their corresponding instance variables. This is useful when we’ve been given a string of XML and need internal consistency in the object.
# File lib/google_apps_oauth2/atom/document.rb, line 22 def find_values @doc.root.each do |entry| intersect = @map.keys & entry.attributes.to_h.keys.map(&:to_sym) set_instances(intersect, entry) unless intersect.empty? end end
parse(xml)
click to toggle source
# File lib/google_apps_oauth2/atom/document.rb, line 11 def parse(xml) document = Atom::XML::Document.string(xml) Atom::XML::Parser.document(document).parse end
set_instances(intersect, node)
click to toggle source
@param [Array] intersect @param [LibXML::XML::Node] node @param [Hash] map
@visibility public @return
# File lib/google_apps_oauth2/atom/document.rb, line 39 def set_instances(intersect, node) intersect.each do |attribute| instance_variable_set "@#{@map[attribute]}", check_value(node.attributes[attribute]) end end