Class: Grenweb::Query
- Inherits:
-
Object
- Object
- Grenweb::Query
- Includes:
- Rack::Utils
- Defined in:
- lib/cdweb/query.rb
Constant Summary collapse
- OPTIONS =
[ ['package', 'p'], ['filepath', 'fpath', 'f'], ['suffix', 's'], ]
Instance Attribute Summary collapse
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #escape_html ⇒ Object
- #fpaths ⇒ Object
-
#initialize(request) ⇒ Query
constructor
A new instance of Query.
- #keywords ⇒ Object
- #packages ⇒ Object
- #suffixs ⇒ Object
Constructor Details
#initialize(request) ⇒ Query
Returns a new instance of Query.
22 23 24 25 26 |
# File 'lib/cdweb/query.rb', line 22 def initialize(request) @query_string = unescape(request.path_info.gsub(/\A\/|\/\z/, '')) init_hash parse end |
Instance Attribute Details
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
14 15 16 |
# File 'lib/cdweb/query.rb', line 14 def query_string @query_string end |
Instance Method Details
#empty? ⇒ Boolean
32 33 34 |
# File 'lib/cdweb/query.rb', line 32 def empty? keywords.size == 0 && packages.size == 0 && fpaths.size == 0 && suffixs.size == 0 end |
#escape_html ⇒ Object
28 29 30 |
# File 'lib/cdweb/query.rb', line 28 def escape_html Rack::Utils::escape_html(@query_string) end |
#fpaths ⇒ Object
44 45 46 |
# File 'lib/cdweb/query.rb', line 44 def fpaths calc_param(1) end |
#keywords ⇒ Object
36 37 38 |
# File 'lib/cdweb/query.rb', line 36 def keywords @hash['keywords'] end |
#packages ⇒ Object
40 41 42 |
# File 'lib/cdweb/query.rb', line 40 def packages calc_param(0) end |
#suffixs ⇒ Object
48 49 50 |
# File 'lib/cdweb/query.rb', line 48 def suffixs calc_param(2) end |