Class: RFC::Web::Link::Models::Link

Inherits:
Data
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rfc/web/link/models/link.rb

Overview

Models a link.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pairsObject (readonly)

Returns the value of attribute pairs

Returns:

  • (Object)

    the current value of pairs



10
11
12
# File 'lib/rfc/web/link/models/link.rb', line 10

def pairs
  @pairs
end

#uriObject (readonly)

Returns the value of attribute uri

Returns:

  • (Object)

    the current value of 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

Returns:

  • (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}"