class Ldp::PreferHeaders
Attributes
headers_string[R]
Public Class Methods
new(headers_string = "")
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 5 def initialize(headers_string = "") @headers_string = headers_string end
Public Instance Methods
include()
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 13 def include @include ||= options["include"] || [] end
include=(vals)
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 21 def include=(vals) @include = Array(vals) serialize end
omit()
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 9 def omit @omit ||= options["omit"] || [] end
omit=(vals)
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 26 def omit=(vals) @omit = Array(vals) serialize end
return()
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 17 def return @return ||= options["return"].first || "" end
return=(vals)
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 31 def return=(vals) @return = Array(vals).first serialize end
to_s()
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 36 def to_s headers_string.to_s end
Private Instance Methods
options()
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 56 def options headers_string.gsub('"', "") .split(";") .map { |x| x.strip.split("=") } .map { |x| { x[0] => x[1].split(" ") } } .inject({}, &:merge) end
serialize()
click to toggle source
# File lib/ldp/client/prefer_headers.rb, line 42 def serialize head_string = [] unless self.return.empty? head_string << "return=#{self.return}" end unless omit.empty? head_string << "omit=\"#{omit.join(" ")}\"" end unless self.include.empty? head_string << "include=\"#{self.include.join(" ")}\"" end @headers_string = head_string.join("; ") end