Class: CodeStock::SearchFiles
- Inherits:
-
Object
- Object
- CodeStock::SearchFiles
- Defined in:
- lib/codestock/cdweb/lib/search_files.rb
Constant Summary collapse
- DISP_NUM =
1ページの表示数
100
Instance Attribute Summary collapse
-
#total_records ⇒ Object
readonly
Returns the value of attribute total_records.
Instance Method Summary collapse
- #data_range ⇒ Object
- #html_contents ⇒ Object
- #html_pagination ⇒ Object
-
#initialize(path, params, query) ⇒ SearchFiles
constructor
A new instance of SearchFiles.
- #next_offset ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(path, params, query) ⇒ SearchFiles
Returns a new instance of SearchFiles.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 18 def initialize(path, params, query) @params = params @q = query @offset = params[:offset].to_i fpaths = @q.fpaths fpaths << path unless path == "" if (fpaths.include?("*")) @records, @total_records = Database.instance.selectAll(@offset, DISP_NUM) else @records, @total_records = Database.instance.search(@q.keywords, @q.packages, fpaths, @q.suffixs, @offset, DISP_NUM) end end |
Instance Attribute Details
#total_records ⇒ Object (readonly)
Returns the value of attribute total_records.
14 15 16 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 14 def total_records @total_records end |
Instance Method Details
#data_range ⇒ Object
42 43 44 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 42 def data_range @offset..(next_offset - 1) end |
#html_contents ⇒ Object
46 47 48 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 46 def html_contents @records.map {|record| result_record(record)}.join end |
#html_pagination ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 50 def html_pagination return "" if @q.empty? return "" if next_offset >= @total_records return <<EOF <div class='pagination'> #{pagination_link(next_offset, "next >>")} </div> EOF end |
#next_offset ⇒ Object
38 39 40 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 38 def next_offset @offset + @records.size end |
#query ⇒ Object
34 35 36 |
# File 'lib/codestock/cdweb/lib/search_files.rb', line 34 def query @q.query_string end |