Project

General

Profile

« Previous | Next » 

Revision dd0ef064

Added by Marc Dequènes over 14 years ago

  • ID dd0ef064621c9134e73e5edee0c70d07804e3529

[evol] adapted for Ruby-Locale 2.0.5

View differences:

lib/http_headers.rb
def reduce(available_language_list)
tag_list = available_language_list.collect do |tag|
l_tag = Locale::Object.new(tag)
l_tag = Locale::Tag.parse(tag).to_rfc
match = []
@sorted_language_list.each do |lr|
match << lr if lr.range == "*" or
lr.range == l_tag.to_iso3066 or
(lr.range + "-" == l_tag.to_iso3066[0, lr.range.size + 1])
lr.range == l_tag.to_s or
(lr.range + "-" == l_tag.to_s[0, lr.range.size + 1])
end
match.sort_by {|lr| lr.range.size }
......
attr_reader :quality
def initialize(lang_range, quality)
@l_lang_range = (lang_range.is_a? Locale::Object) ? lang_range : Locale::Object.new(lang_range)
@l_lang_range = (lang_range.is_a? Locale::Tag::Simple) ? lang_range : Locale::Tag.parse(lang_range).to_rfc
@quality = quality.to_f
end
def range
@l_lang_range.to_iso3066
@l_lang_range.to_s
end
def <=>(lr)

Also available in: Unified diff