Class: Cheatorious::Search
- Inherits:
-
Object
- Object
- Cheatorious::Search
- Defined in:
- lib/cheatorious/search.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute(query = "", writer = Writer::Text, options = {}) ⇒ Object
-
#initialize(cheat_model) ⇒ Search
constructor
A new instance of Search.
Constructor Details
#initialize(cheat_model) ⇒ Search
Returns a new instance of Search.
11 12 13 14 |
# File 'lib/cheatorious/search.rb', line 11 def initialize(cheat_model) cheat_model = Utils.deserialize(cheat_model, Utils.serialization_type(cheat_model)) if cheat_model.kind_of?(String) @cheat_model = cheat_model end |
Class Method Details
Instance Method Details
#execute(query = "", writer = Writer::Text, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cheatorious/search.rb', line 16 def execute(query = "", writer = Writer::Text, = {}) info = @cheat_model[:info] .delete("reverse") if ["section"] && ["reverse"] # Filtering filtered = @cheat_model[:cheatsheet][:root].dup unless print_full?(query) filtered, results_count = depth_search(query, filtered, ) end # Writing w = writer.new print_full?(query) ? w.header(info[:name], info[:author], info[:version], info[:description]) : w.search_header(query, results_count, ) write_contents(filtered, w, ) w. return w.result end |