Class: Milkode::SearchFuzzyGotoLine
- Inherits:
-
Object
- Object
- Milkode::SearchFuzzyGotoLine
- Defined in:
- lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb
Defined Under Namespace
Classes: MatchRecord
Constant Summary collapse
- DISP_NUM =
1ページの表示数
20
- LIMIT_NUM =
最大検索ファイル数
50
- NTH =
表示範囲
3
- COL_LIMIT =
1行の桁制限
200
Instance Attribute Summary collapse
-
#end_index ⇒ Object
readonly
Returns the value of attribute end_index.
-
#match_records ⇒ Object
readonly
Returns the value of attribute match_records.
-
#next_index ⇒ Object
readonly
Returns the value of attribute next_index.
-
#total_records ⇒ Object
readonly
Returns the value of attribute total_records.
Instance Method Summary collapse
- #data_range ⇒ Object
- #directjump? ⇒ Boolean
- #directjump_url ⇒ Object
- #html_contents ⇒ Object
- #html_pagination ⇒ Object
-
#initialize(path, params, query, suburl) ⇒ SearchFuzzyGotoLine
constructor
A new instance of SearchFuzzyGotoLine.
- #match_num ⇒ Object
- #next_offset ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(path, params, query, suburl) ⇒ SearchFuzzyGotoLine
Returns a new instance of SearchFuzzyGotoLine.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 25 def initialize(path, params, query, suburl) @path = path @params = params @q = query @page = params[:page].to_i || 0 @offset = params[:offset].to_i @suburl = suburl @homeurl = @suburl + "/home/" # 検索クエリを解析 gotolines = Util.parse_gotoline(@q.gotolines + @q.keywords) @gotoline = gotolines[0] # 検索 fpaths = @q.fpaths + @gotoline[0] @records, @total_records = Database.instance.search([], @q.multi_match_keywords, @q.packages, path, fpaths, @q.suffixs, @q.fpath_or_packages, @offset, LIMIT_NUM) # 検索結果を表示 grep_contents end |
Instance Attribute Details
#end_index ⇒ Object (readonly)
Returns the value of attribute end_index.
18 19 20 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 18 def end_index @end_index end |
#match_records ⇒ Object (readonly)
Returns the value of attribute match_records.
16 17 18 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 16 def match_records @match_records end |
#next_index ⇒ Object (readonly)
Returns the value of attribute next_index.
17 18 19 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 17 def next_index @next_index end |
#total_records ⇒ Object (readonly)
Returns the value of attribute total_records.
15 16 17 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 15 def total_records @total_records end |
Instance Method Details
#data_range ⇒ Object
54 55 56 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 54 def data_range @offset..(@offset + @end_index) end |
#directjump? ⇒ Boolean
84 85 86 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 84 def directjump? match_num == 1 end |
#directjump_url ⇒ Object
88 89 90 91 92 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 88 def directjump_url path = @homeurl + @match_records[0].record.shortpath lineno = "#n#{@gotoline[1]}" Mkurl.new(path, @params).inherit_query_shead + lineno end |
#html_contents ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 58 def html_contents match_groups = @match_records.reduce([]) do |g, m| # 近接マッチ無効 g << [m] end <<EOF #{match_groups.map{|g|result_match_record(g)}.join} EOF end |
#html_pagination ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 69 def html_pagination return "" if @q.empty? return "" if next_offset >= @total_records return <<EOF <div class='pagination pagination-centered'> #{pagination_link(next_offset, @next_line, "next >>")} </div> EOF end |
#match_num ⇒ Object
80 81 82 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 80 def match_num @match_records.size end |
#next_offset ⇒ Object
50 51 52 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 50 def next_offset @offset + @next_index end |
#query ⇒ Object
46 47 48 |
# File 'lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb', line 46 def query @q.query_string end |