class Oembedr::ParsedUrl

Attributes

raw_url[RW]
url[RW]

Public Class Methods

new(the_url) click to toggle source

TODO: support xml at some point :)

# File lib/oembedr/parsed_url.rb, line 11
def initialize the_url
  self.raw_url = the_url
  endpoint = service_endpoint(raw_url)
  if endpoint
    self.url = URI.parse(endpoint.gsub(/\{format\}/, "json"))
  else
    self.url = false
  end
end

Public Instance Methods

host() click to toggle source

Returns the scheme and host portion of the uri, intelligently concatenated

Examples

self.new("https://twitter.com/#!/hypomodern").host # => "https://twitter.com"
self.new("http://youtu.be/v/234543").host # => "http://youtube.com"

@return url [String]

# File lib/oembedr/parsed_url.rb, line 29
def host
  return false unless url
  url.scheme + "://" + url.host
end
path() click to toggle source

Returns the path portion of the uri

@return path [String]

# File lib/oembedr/parsed_url.rb, line 37
def path
  return false unless url
  url.path
end