Class: HTTP::Accept::Charsets::Charset
- Inherits:
-
Struct
- Object
- Struct
- HTTP::Accept::Charsets::Charset
- Defined in:
- lib/http/accept/charsets.rb
Instance Attribute Summary collapse
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#q ⇒ Object
Returns the value of attribute q.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#charset ⇒ Object
Returns the value of attribute charset
22 23 24 |
# File 'lib/http/accept/charsets.rb', line 22 def charset @charset end |
#q ⇒ Object
Returns the value of attribute q
22 23 24 |
# File 'lib/http/accept/charsets.rb', line 22 def q @q end |
Class Method Details
.parse(scanner) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/http/accept/charsets.rb', line 27 def self.parse(scanner) return to_enum(:parse, scanner) unless block_given? while scanner.scan(CHARSETS) yield self.new(scanner[:charset], scanner[:q]) # Are there more? break unless scanner.scan(/\s*,\s*/) end raise ParseError.new('Could not parse entire string!') unless scanner.eos? end |
Instance Method Details
#quality_factor ⇒ Object
23 24 25 |
# File 'lib/http/accept/charsets.rb', line 23 def quality_factor (q || 1.0).to_f end |