Sha256: ea532ce8ac81404490b946442ca8ce1c3d510e39b34e01c13c4b2c362e8e5d72
Contents?: true
Size: 989 Bytes
Versions: 1
Compression:
Stored size: 989 Bytes
Contents
module LinkHeaderParser class LinkHeaderParameter PARAMETER_REGEXP_PATTERN = /^(?<name>.+?)(?:="?(?<value>.*?)"?)?$/.freeze attr_reader :parameter # @param parameter [String] def initialize(parameter) @parameter = parameter.to_str end def inspect format(%(#<#{self.class.name}:%#0x name: #{name.inspect}, value: #{value.inspect}>), object_id) end # @see https://tools.ietf.org/html/rfc8288#appendix-B.3 (Appendix B.3.2.9) # # @return [String] def name @name ||= parameter_match_data[:name].downcase end # @see https://tools.ietf.org/html/rfc8288#appendix-B.3 (Appendix B.3.2.8) # # @return [String] def value @value ||= parameter_match_data[:value].to_s end # @return [Array<String>] def to_ary [name, value] end alias to_a to_ary private def parameter_match_data @parameter_match_data ||= parameter.match(PARAMETER_REGEXP_PATTERN) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
link-header-parser-3.0.0 | lib/link_header_parser/link_header_parameter.rb |