class Zeli::Parser::HeaderParser

Public Class Methods

new(option) click to toggle source
# File lib/zeli/parsers/header_parser.rb, line 4
def initialize(option)
  @option = option
end

Public Instance Methods

headers() click to toggle source
# File lib/zeli/parsers/header_parser.rb, line 20
def headers
  value.map do |header|
    k, v = header.split(': ')
    k = k[1..-1] if k.start_with? '"'
    v = v[0..-2] if v.end_with? '"'

    [k, v]
  end.to_h
end
parse!(raw_curl, curl) click to toggle source
# File lib/zeli/parsers/header_parser.rb, line 8
def parse!(raw_curl, curl)
  @raw_curl = raw_curl
  @curl = curl

  @curl.headers.merge!(headers)
end
value() click to toggle source
# File lib/zeli/parsers/header_parser.rb, line 15
def value
  result = @raw_curl.scan(/\s#{@option}\ (.*)(\\)(\s?)/)
  result.map &:first
end