Class: Picky::Try
Overview
Try is used by
rake try[text,index,category]
to test how the text would be indexed and processed during a search.
Instance Attribute Summary collapse
-
#specific ⇒ Object
readonly
Returns the value of attribute specific.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text, index = nil, category = nil) ⇒ Try
constructor
A new instance of Try.
- #output ⇒ Object
- #saved ⇒ Object
- #searched ⇒ Object
- #to_stdout ⇒ Object
Constructor Details
#initialize(text, index = nil, category = nil) ⇒ Try
Returns a new instance of Try.
11 12 13 14 15 16 |
# File 'lib/tasks/try.rb', line 11 def initialize text, index = nil, category = nil @text = text @specific = Picky::Indexes @specific = @specific[index.intern] if index @specific = @specific[category.intern] if category end |
Instance Attribute Details
#specific ⇒ Object (readonly)
Returns the value of attribute specific.
9 10 11 |
# File 'lib/tasks/try.rb', line 9 def specific @specific end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/tasks/try.rb', line 9 def text @text end |
Instance Method Details
#output ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/tasks/try.rb', line 26 def output "\\\"\#{text}\\\" is saved in the \#{specific.identifier} index as \#{saved}\n\\\"\#{text}\\\" as a search will be tokenized as \#{searched}\n\n(category qualifiers, e.g. title: are removed if they do not exist as a qualifier, so 'toitle:bla' -> 'bla')\n OUTPUT\nend\n" |
#saved ⇒ Object
18 19 20 |
# File 'lib/tasks/try.rb', line 18 def saved specific.tokenizer.tokenize(text.dup).first end |
#searched ⇒ Object
22 23 24 |
# File 'lib/tasks/try.rb', line 22 def searched Picky::Tokenizer.searching.tokenize(text.dup).first end |
#to_stdout ⇒ Object
35 36 37 |
# File 'lib/tasks/try.rb', line 35 def to_stdout puts output end |