Class: Waves::Request::Accept
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse(string) ⇒ Object
90 91 92 |
# File 'lib/runtime/request.rb', line 90 def self.parse(string) string.split(',').inject(self.new) { |a, entry| a << entry.split( ';' ).first.strip; a } end |
Instance Method Details
#===(arg) ⇒ Object
74 |
# File 'lib/runtime/request.rb', line 74 def ===(arg) ; self.include? arg ; end |
#=~(arg) ⇒ Object
73 |
# File 'lib/runtime/request.rb', line 73 def =~(arg) ; self.include? arg ; end |
#default ⇒ Object
94 95 96 97 |
# File 'lib/runtime/request.rb', line 94 def default return 'text/html' if self.include?('text/html') find { |entry| ! entry.match(/\*/) } || 'text/html' end |
#include?(arg) ⇒ Boolean
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/runtime/request.rb', line 76 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 |