Class: HTTP::Accept::QuotedString

Inherits:
Object
  • Object
show all
Defined in:
lib/http/accept/quoted_string.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ QuotedString

Returns a new instance of QuotedString.



28
29
30
# File 'lib/http/accept/quoted_string.rb', line 28

def initialize(value)
	@value = value
end

Instance Method Details

#to_sObject



48
49
50
# File 'lib/http/accept/quoted_string.rb', line 48

def to_s
	to_str
end

#to_strObject



44
45
46
# File 'lib/http/accept/quoted_string.rb', line 44

def to_str
	unquote(true)
end

#unquote(normalize_whitespace = false) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/http/accept/quoted_string.rb', line 32

def unquote(normalize_whitespace = false)
	value = @value[1...-1]
	
	value.gsub!(/\\(.)/, '\1') 
	
	if normalize_whitespace
		value = value.gsub!(/[\r\n](\s+)+/, ' ')
	end
	
	return value
end