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
79 80 81 |
# File 'lib/http/accept/languages.rb', line 79 def locale @locale end |
#q ⇒ Object
Returns the value of attribute q
79 80 81 |
# File 'lib/http/accept/languages.rb', line 79 def q @q end |
Class Method Details
.parse(scanner) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/http/accept/languages.rb', line 84 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? return unless scanner.scan(/\s*,\s*/) end raise ParseError.new("Could not parse entire string!") unless scanner.eos? end |
Instance Method Details
#quality_factor ⇒ Object
80 81 82 |
# File 'lib/http/accept/languages.rb', line 80 def quality_factor (q || 1.0).to_f end |