Class: HTTP::Accept::Languages::LanguageRange
- Inherits:
-
Struct
- Object
- Struct
- HTTP::Accept::Languages::LanguageRange
- Defined in:
- lib/http/accept/languages.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#q ⇒ Object
Returns the value of attribute q.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#locale ⇒ Object
Returns the value of attribute locale
101 102 103 |
# File 'lib/http/accept/languages.rb', line 101 def locale @locale end |
#q ⇒ Object
Returns the value of attribute q
101 102 103 |
# File 'lib/http/accept/languages.rb', line 101 def q @q end |
Class Method Details
.parse(scanner) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/http/accept/languages.rb', line 106 def self.parse(scanner) return to_enum(:parse, scanner) unless block_given? while scanner.scan(LANGUAGE_RANGE) yield self.new(scanner[:locale], 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
102 103 104 |
# File 'lib/http/accept/languages.rb', line 102 def quality_factor (q || 1.0).to_f end |