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
85 86 87 |
# File 'lib/http/accept/languages.rb', line 85 def locale @locale end |
#q ⇒ Object
Returns the value of attribute q
85 86 87 |
# File 'lib/http/accept/languages.rb', line 85 def q @q end |
Class Method Details
.parse(scanner) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/http/accept/languages.rb', line 90 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
86 87 88 |
# File 'lib/http/accept/languages.rb', line 86 def quality_factor (q || 1.0).to_f end |