lib/genderize/io/parser/header.rb in genderize-io-1.1.0 vs lib/genderize/io/parser/header.rb in genderize-io-1.2.0

- old
+ new

@@ -21,20 +21,24 @@ def parse @headers = @response.split(/\\r\\n|\n|\r/) end - def method_missing(sym, *_args) - detect_multi_value_keys(sym) + def method_missing(sym, *) + detect_multi_value_keys(sym) || super end + def respond_to_missing?(sym, *) + detect_multi_value_keys(sym) || super + end + def response_code - @headers[0].match(/HTTP\/\d\.\d (\d{3}.*)/)[1] + @headers[0].match(%r{HTTP/\d\.\d (\d{3}.*)})[1] end def version - @headers[0].match(/HTTP\/\d\.\d/)[0] + @headers[0].match(%r{HTTP/\d\.\d})[0] end private def detect_multi_value_keys(tag) @@ -48,10 +52,10 @@ sym.to_s.gsub('_', replacement) end def value_from(tag) val = tag.split(/:\s+/)[1] - val =~ /^\"(.*)\"$/ ? $1 : val + val =~ /^\"(.*)\"$/ ? Regexp.last_match(1) : val end end end end