Class: Ocular::Inputs::HTTP::Input::Request::AcceptEntry
- Inherits:
-
Object
- Object
- Ocular::Inputs::HTTP::Input::Request::AcceptEntry
show all
- Defined in:
- lib/ocular/inputs/http_input.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of AcceptEntry.
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/ocular/inputs/http_input.rb', line 136
def initialize(entry)
params = entry.scan().map! do |s|
key, value = s.strip.split('=', 2)
value = value[1..-2].gsub(/\\(.)/, '\1') if value.start_with?('"')
[key, value]
end
@entry = entry
@type = entry[/[^;]+/].delete(' ')
@params = Hash[params]
@q = @params.delete('q') { 1.0 }.to_f
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
170
171
172
|
# File 'lib/ocular/inputs/http_input.rb', line 170
def method_missing(*args, &block)
to_str.send(*args, &block)
end
|
Instance Attribute Details
#entry ⇒ Object
Returns the value of attribute entry.
134
135
136
|
# File 'lib/ocular/inputs/http_input.rb', line 134
def entry
@entry
end
|
#params ⇒ Object
Returns the value of attribute params.
133
134
135
|
# File 'lib/ocular/inputs/http_input.rb', line 133
def params
@params
end
|
Instance Method Details
#<=>(other) ⇒ Object
149
150
151
|
# File 'lib/ocular/inputs/http_input.rb', line 149
def <=>(other)
other.priority <=> self.priority
end
|
#priority ⇒ Object
153
154
155
156
|
# File 'lib/ocular/inputs/http_input.rb', line 153
def priority
[ @q, -@type.count('*'), @params.size ]
end
|
#respond_to?(*args) ⇒ Boolean
166
167
168
|
# File 'lib/ocular/inputs/http_input.rb', line 166
def respond_to?(*args)
super or to_str.respond_to?(*args)
end
|
#to_s(full = false) ⇒ Object
162
163
164
|
# File 'lib/ocular/inputs/http_input.rb', line 162
def to_s(full = false)
full ? entry : to_str
end
|
#to_str ⇒ Object
158
159
160
|
# File 'lib/ocular/inputs/http_input.rb', line 158
def to_str
@type
end
|