Class: Milkode::SearchFiles
- Inherits:
-
Object
- Object
- Milkode::SearchFiles
- Defined in:
- lib/milkode/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, suburl) ⇒ SearchFiles
constructor
A new instance of SearchFiles.
- #match_num ⇒ Object
- #next_offset ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(path, params, query, suburl) ⇒ SearchFiles
Returns a new instance of SearchFiles.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 20 def initialize(path, params, query, suburl) @path = path @params = params @q = query @suburl = suburl @homeurl = @suburl + "/home/" @offset = params[:offset].to_i if (@q.fpaths.include?("*")) @records, @total_records = Database.instance.selectAll(path, @offset, DISP_NUM) else @records, @total_records = Database.instance.search(@q.keywords, @q.multi_match_keywords, @q.packages, path, @q.fpaths, @q.suffixs, @q.fpath_or_packages, @offset, DISP_NUM) end end |
Instance Attribute Details
#total_records ⇒ Object (readonly)
Returns the value of attribute total_records.
16 17 18 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 16 def total_records @total_records end |
Instance Method Details
#data_range ⇒ Object
44 45 46 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 44 def data_range @offset..(next_offset - 1) end |
#html_contents ⇒ Object
48 49 50 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 48 def html_contents @records.map {|record| result_record(DocumentRecord.new(record))}.join end |
#html_pagination ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 52 def html_pagination return "" if @q.empty? return "" if @total_records < DISP_NUM return <<EOF <div class='pagination pagination-centered'> #{pagination_link(next_offset, "next >>")} </div> EOF end |
#match_num ⇒ Object
63 64 65 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 63 def match_num @records.size end |
#next_offset ⇒ Object
40 41 42 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 40 def next_offset @offset + @records.size end |
#query ⇒ Object
36 37 38 |
# File 'lib/milkode/cdweb/lib/search_files.rb', line 36 def query @q.query_string end |