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) ⇒ Url

Create a new Webmention::Url.

Parameters:

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

    An absolute URL.



17
18
19
# File 'lib/webmention/url.rb', line 17

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)


23
24
25
26
# File 'lib/webmention/url.rb', line 23

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

#responseResponse, ErrorResponse

Returns:



30
31
32
# File 'lib/webmention/url.rb', line 30

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

#webmention_endpointString?

Returns:

  • (String, nil)


35
36
37
# File 'lib/webmention/url.rb', line 35

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

#webmention_endpoint?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/webmention/url.rb', line 40

def webmention_endpoint?
  !webmention_endpoint.nil?
end