Class: HTTP::Accept::QuotedString
- Inherits:
-
Object
- Object
- HTTP::Accept::QuotedString
- Defined in:
- lib/http/accept/quoted_string.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ QuotedString
constructor
A new instance of QuotedString.
- #to_s ⇒ Object
- #to_str ⇒ Object
- #unquote(normalize_whitespace = false) ⇒ Object
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_s ⇒ Object
48 49 50 |
# File 'lib/http/accept/quoted_string.rb', line 48 def to_s to_str end |
#to_str ⇒ Object
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 |