Class: HttpLinkHeader::HttpLinkParams::RelationTypes
- Inherits:
-
Set
- Object
- Set
- HttpLinkHeader::HttpLinkParams::RelationTypes
- Defined in:
- lib/http_link_header/http_link_params.rb
Instance Method Summary collapse
- #add(relation_types) ⇒ Object
- #include?(relation_type) ⇒ Boolean
-
#initialize(relation_types) ⇒ RelationTypes
constructor
A new instance of RelationTypes.
- #to_s ⇒ Object
Constructor Details
#initialize(relation_types) ⇒ RelationTypes
Returns a new instance of RelationTypes.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/http_link_header/http_link_params.rb', line 9 def initialize(relation_types) if relation_types.is_a?(Enumerable) super(relation_types) elsif relation_types.is_a?(String) super() add(relation_types) else raise ArgumentError, "invalid relation-types: #{relation_types}" end end |
Instance Method Details
#add(relation_types) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/http_link_header/http_link_params.rb', line 20 def add(relation_types) relation_types.strip.gsub!(/\A"|"\z/, '').split(' ').each do |relation_type| relation_type = relation_type.strip super(relation_type.downcase) unless relation_type.empty? end end |
#include?(relation_type) ⇒ Boolean
27 28 29 |
# File 'lib/http_link_header/http_link_params.rb', line 27 def include?(relation_type) super(relation_type.downcase) end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/http_link_header/http_link_params.rb', line 31 def to_s %Q{"#{to_a.join(' ')}"} end |