Class: Webmention::Url

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/webmention/url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Webmention::Url

Create a new Webmention::Url.

Parameters:

  • url (String, HTTP::URI, #to_s)

    An absolute URL.



19
20
21
# File 'lib/webmention/url.rb', line 19

def initialize(url)
  @uri = HTTP::URI.parse(url.to_s)
end

Instance Attribute Details

#uriString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/webmention/url.rb', line 8

def uri
  @uri
end

Instance Method Details

#inspectString

:nocov:

Returns:

  • (String)


25
26
27
28
# File 'lib/webmention/url.rb', line 25

def inspect
  "#<#{self.class}:#{format("%#0x", object_id)} " \
    "uri: #{uri}>"
end

#responseWebmention::Response, Webmention::ErrorResponse



32
33
34
# File 'lib/webmention/url.rb', line 32

def response
  @response ||= Request.get(uri)
end

#webmention_endpointString?

Returns:

  • (String, nil)


37
38
39
# File 'lib/webmention/url.rb', line 37

def webmention_endpoint
  @webmention_endpoint ||= IndieWeb::Endpoints::Parser.new(response).results[:webmention] if response.ok?
end

#webmention_endpoint?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/webmention/url.rb', line 42

def webmention_endpoint?
  !webmention_endpoint.nil?
end