Class: Waves::Request::Accept
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse(string) ⇒ Object
96 97 98 |
# File 'lib/runtime/request.rb', line 96 def self.parse(string) string.split(',').inject(self.new) { |a, entry| a << entry.split( ';' ).first.strip; a } end |
Instance Method Details
#===(arg) ⇒ Object
80 |
# File 'lib/runtime/request.rb', line 80 def ===(arg) ; self.include? arg ; end |
#=~(arg) ⇒ Object
79 |
# File 'lib/runtime/request.rb', line 79 def =~(arg) ; self.include? arg ; end |
#default ⇒ Object
100 101 102 103 |
# File 'lib/runtime/request.rb', line 100 def default return 'text/html' if self.include?('text/html') find { |entry| ! entry.match(/\*/) } || 'text/html' end |
#include?(arg) ⇒ Boolean
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/runtime/request.rb', line 82 def include?(arg) return arg.any? { |pat| self.include?( pat ) } if arg.is_a? Array arg = arg.to_s.split('/') self.any? do |entry| false if entry == '*/*' or entry == '*' entry = entry.split('/') if arg.size == 1 # implicit wildcard in arg arg[0] == entry[0] or arg[0] == entry[1] else arg == entry end end end |