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.
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/ocular/inputs/http_input.rb', line 163
def initialize(entry)
params = entry.scan(HEADER_PARAM).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
197
198
199
|
# File 'lib/ocular/inputs/http_input.rb', line 197
def method_missing(*args, &block)
to_str.send(*args, &block)
end
|
Instance Attribute Details
#entry ⇒ Object
Returns the value of attribute entry.
161
162
163
|
# File 'lib/ocular/inputs/http_input.rb', line 161
def entry
@entry
end
|
#params ⇒ Object
Returns the value of attribute params.
160
161
162
|
# File 'lib/ocular/inputs/http_input.rb', line 160
def params
@params
end
|
Instance Method Details
#<=>(other) ⇒ Object
176
177
178
|
# File 'lib/ocular/inputs/http_input.rb', line 176
def <=>(other)
other.priority <=> self.priority
end
|
#priority ⇒ Object
180
181
182
183
|
# File 'lib/ocular/inputs/http_input.rb', line 180
def priority
[ @q, -@type.count('*'), @params.size ]
end
|
#respond_to?(*args) ⇒ Boolean
193
194
195
|
# File 'lib/ocular/inputs/http_input.rb', line 193
def respond_to?(*args)
super or to_str.respond_to?(*args)
end
|
#to_s(full = false) ⇒ Object
189
190
191
|
# File 'lib/ocular/inputs/http_input.rb', line 189
def to_s(full = false)
full ? entry : to_str
end
|
#to_str ⇒ Object
185
186
187
|
# File 'lib/ocular/inputs/http_input.rb', line 185
def to_str
@type
end
|