pkg/rbvimeo-0.1.0/lib/Video.rb
# Parses data using the xml recieved from the Vimeo REST API
# Should not need to be called by anything other than the initialize method
Parses data using the xml recieved from the Vimeo REST API
Should not need to be called by anything other than the initialize method
Parses data using the xml recieved from the Vimeo REST API Should not need to be called by anything other than the initialize method
def parse_xml xml_doc
      if xml_doc.elements["rsp/video/title"].nil?
        return nil
      else
        @title = xml_doc.elements["rsp/video/title"].text
        @id = id
        @caption = xml_doc.elements["rsp/video/caption"].text
        @upload_date = xml_doc.elements["rsp/video/upload_date"].text
        @likes = xml_doc.elements["rsp/video/number_of_likes"].text.to_i
        @plays = xml_doc.elements["rsp/video/number_of_plays"].text.to_i
        @width = xml_doc.elements["rsp/video/width"].text.to_i
        @height = xml_doc.elements["rsp/video/height"].text.to_i
        @num_comments =
          xml_doc.elements["rsp/video/number_of_comments"].text.to_i
        @owner = User.new
        @owner.id = xml_doc.elements["rsp/video/owner"].attributes["id"].to_i
        @owner.username =
          xml_doc.elements["rsp/video/owner"].attributes["username"]
        @owner.fullname =
          xml_doc.elements["rsp/video/owner"].attributes["fullname"]
        @url = xml_doc.elements["rsp/video/urls/url"].text
        xml_doc.elements.each('rsp/video/thumbnails/thumbnail') do |thumb|
          url = thumb.text
          w = thumb.attributes["width"].to_i
          h = thumb.attributes["height"].to_i
          thumbnail = Thumbnail.new(url, w, h)
          @thumbs << thumbnail
        end
      end
    end
def parse_xml xml_doc if xml_doc . elements [ "rsp/video/title" ] . nil? return nil else @title = xml_doc . elements [ "rsp/video/title" ] . text @id = id @caption = xml_doc . elements [ "rsp/video/caption" ] . text @upload_date = xml_doc . elements [ "rsp/video/upload_date" ] . text @likes = xml_doc . elements [ "rsp/video/number_of_likes" ] . text . to_i @plays = xml_doc . elements [ "rsp/video/number_of_plays" ] . text . to_i @width = xml_doc . elements [ "rsp/video/width" ] . text . to_i @height = xml_doc . elements [ "rsp/video/height" ] . text . to_i @num_comments = xml_doc . elements [ "rsp/video/number_of_comments" ] . text . to_i @owner = User . new @owner . id = xml_doc . elements [ "rsp/video/owner" ] . attributes [ "id" ] . to_i @owner . username = xml_doc . elements [ "rsp/video/owner" ] . attributes [ "username" ] @owner . fullname = xml_doc . elements [ "rsp/video/owner" ] . attributes [ "fullname" ] @url = xml_doc . elements [ "rsp/video/urls/url" ] . text xml_doc . elements . each ( 'rsp/video/thumbnails/thumbnail' ) do | thumb | url = thumb . text w = thumb . attributes [ "width" ] . to_i h = thumb . attributes [ "height" ] . to_i thumbnail = Thumbnail . new ( url , w , h ) @thumbs << thumbnail end end end
Parses data using the xml recieved from the Vimeo REST API
Should not need to be called by anything other than the initialize method
Parses data using the xml recieved from the Vimeo REST API Should not need to be called by anything other than the initialize method
xml_doc