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
99 100 101 |
# File 'lib/http/accept/languages.rb', line 99 def locale @locale end |
#q ⇒ Object
Returns the value of attribute q
99 100 101 |
# File 'lib/http/accept/languages.rb', line 99 def q @q end |
Class Method Details
.parse(scanner) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/http/accept/languages.rb', line 104 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
100 101 102 |
# File 'lib/http/accept/languages.rb', line 100 def quality_factor (q || 1.0).to_f end |