Class: LinkHeaderParser::LinkHeaderParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/link_header_parser/link_header_parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameter) ⇒ LinkHeaderParameter

Create a new parsed Link header parameter.

Parameters:

  • parameter (String, #to_str)


16
17
18
# File 'lib/link_header_parser/link_header_parameter.rb', line 16

def initialize(parameter)
  @parameter = parameter.to_str
end

Instance Attribute Details

#parameterString (readonly)

The String value used to create this LinkHeaderParser::LinkHeaderParameter.

Returns:

  • (String)


11
12
13
# File 'lib/link_header_parser/link_header_parameter.rb', line 11

def parameter
  @parameter
end

Instance Method Details

#inspectString

Returns:

  • (String)


21
22
23
24
25
# File 'lib/link_header_parser/link_header_parameter.rb', line 21

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

#nameString



31
32
33
# File 'lib/link_header_parser/link_header_parameter.rb', line 31

def name
  @name ||= parameter_match_data[:name].downcase
end

#to_aryArray<String> Also known as: to_a

Return an Array representation of this LinkHeaderParser::LinkHeaderParameter.

Returns:

  • (Array<String>)


46
47
48
# File 'lib/link_header_parser/link_header_parameter.rb', line 46

def to_ary
  [name, value]
end

#valueString



39
40
41
# File 'lib/link_header_parser/link_header_parameter.rb', line 39

def value
  @value ||= parameter_match_data[:value].to_s
end