Class: RFC::Web::Link::Models::Link
- Inherits:
-
Data
- Object
- Data
- RFC::Web::Link::Models::Link
- Extended by:
- Forwardable
- Defined in:
- lib/rfc/web/link/models/link.rb
Overview
Models a link.
Instance Attribute Summary collapse
-
#pairs ⇒ Object
readonly
Returns the value of attribute pairs.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #add(pair) ⇒ Object
- #append(key, value, **attributes) ⇒ Object
- #has?(key) ⇒ Boolean
-
#initialize(uri:, pairs: Set.new) ⇒ Link
constructor
A new instance of Link.
- #to_s(delimiter: "; ") ⇒ Object (also: #to_str)
Constructor Details
#initialize(uri:, pairs: Set.new) ⇒ Link
Returns a new instance of Link.
15 16 17 |
# File 'lib/rfc/web/link/models/link.rb', line 15 def initialize uri:, pairs: Set.new super end |
Instance Attribute Details
#pairs ⇒ Object (readonly)
Returns the value of attribute pairs
10 11 12 |
# File 'lib/rfc/web/link/models/link.rb', line 10 def pairs @pairs end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri
10 11 12 |
# File 'lib/rfc/web/link/models/link.rb', line 10 def uri @uri end |
Instance Method Details
#add(pair) ⇒ Object
19 20 21 22 |
# File 'lib/rfc/web/link/models/link.rb', line 19 def add pair pairs.add pair self end |
#append(key, value, **attributes) ⇒ Object
24 25 26 27 |
# File 'lib/rfc/web/link/models/link.rb', line 24 def append key, value, **attributes pairs.add Pair[key:, value:, **attributes] self end |
#has?(key) ⇒ Boolean
29 |
# File 'lib/rfc/web/link/models/link.rb', line 29 def has?(key) = pairs.any? { it.key == key.to_s } |
#to_s(delimiter: "; ") ⇒ Object Also known as: to_str
31 |
# File 'lib/rfc/web/link/models/link.rb', line 31 def to_s(delimiter: "; ") = "<#{uri}>; #{pairs.join delimiter}" |