Class: Bridgetown::Webfinger::Link
- Inherits:
-
Object
- Object
- Bridgetown::Webfinger::Link
- Extended by:
- Logging
- Defined in:
- lib/bridgetown/webfinger/link.rb
Overview
Instance Attribute Summary collapse
-
#href ⇒ Href?
readonly
private
The optional hypertext reference to a URI for the Link.
-
#properties ⇒ Properties?
readonly
private
The optional Properties characterizing the Link.
-
#rel ⇒ LinkRelationType
readonly
private
The LinkRelationType describing what the Link links to.
- #titles ⇒ Titles? readonly private
- #type ⇒ String? readonly private
Class Method Summary collapse
-
.parse(data) ⇒ Link?
private
Parses and maybe-returns a Link when the value is one.
Instance Method Summary collapse
-
#initialize(rel:, href: nil, properties: nil, titles: nil, type: nil) ⇒ Link
constructor
private
Creates a new Link.
-
#to_h ⇒ Hash
private
Converts the Link into a JSON-serializable Hash.
Methods included from Logging
Constructor Details
#initialize(rel:, href: nil, properties: nil, titles: nil, type: nil) ⇒ Link
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new Bridgetown::Webfinger::Link
53 54 55 56 57 58 59 |
# File 'lib/bridgetown/webfinger/link.rb', line 53 def initialize(rel:, href: nil, properties: nil, titles: nil, type: nil) @href = href @properties = properties @rel = rel @titles = titles @type = type end |
Instance Attribute Details
#href ⇒ Href? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional hypertext reference to a URI for the Bridgetown::Webfinger::Link
67 68 69 |
# File 'lib/bridgetown/webfinger/link.rb', line 67 def href @href end |
#properties ⇒ Properties? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional Properties characterizing the Bridgetown::Webfinger::Link
76 77 78 |
# File 'lib/bridgetown/webfinger/link.rb', line 76 def properties @properties end |
#rel ⇒ LinkRelationType (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The Bridgetown::Webfinger::LinkRelationType describing what the Bridgetown::Webfinger::Link links to
84 85 86 |
# File 'lib/bridgetown/webfinger/link.rb', line 84 def rel @rel end |
#titles ⇒ Titles? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional Titles describing the Bridgetown::Webfinger::Link
92 93 94 |
# File 'lib/bridgetown/webfinger/link.rb', line 92 def titles @titles end |
#type ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional media type of the #href for the Bridgetown::Webfinger::Link
100 101 102 |
# File 'lib/bridgetown/webfinger/link.rb', line 100 def type @type end |
Class Method Details
.parse(data) ⇒ Link?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parses and maybe-returns a Bridgetown::Webfinger::Link when the value is one
- Links][1
-
within the JRD are member objects representing a link to
another resource.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bridgetown/webfinger/link.rb', line 26 def self.parse(data) unless (rel = LinkRelationType.parse(data[:rel])) return warn( "Webfinger link rel is missing or malformed: #{data.inspect}, ignoring" ) end new( rel: rel, href: Href.parse(data[:href]), properties: Properties.parse(data[:properties]), titles: Titles.parse(data[:titles]), type: data[:type] ) end |
Instance Method Details
#to_h ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the Bridgetown::Webfinger::Link into a JSON-serializable Hash
108 109 110 111 112 113 114 115 |
# File 'lib/bridgetown/webfinger/link.rb', line 108 def to_h result = {rel: rel} result[:href] = href if href result[:properties] = properties if properties result[:titles] = titles if titles result[:type] = type if type result end |