Sha256: 12e32ce7393594477c0a55d718559adc2cfdd9e13e6770db0cd048f1987b1a7b

Contents?: true

Size: 791 Bytes

Versions: 22

Compression:

Stored size: 791 Bytes

Contents

module Picky

  class Try

    attr_reader :text, :specific

    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

    def saved
      specific.tokenizer.tokenize(text.dup).first
    end

    def searched
      Picky::Tokenizer.query_default.tokenize(text.dup).first
    end

    def output
      <<-OUTPUT
\"#{text}\" is saved in the #{specific.identifier} index as #{saved}
\"#{text}\" as a search will be tokenized as #{searched}

(category qualifiers, e.g. title: are removed if they do not exist as a qualifier, so 'toitle:bla' -> 'bla')
      OUTPUT
    end

    def to_stdout
      puts output
    end

  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
picky-4.0.0pre1 lib/tasks/try.rb
picky-3.6.16 lib/tasks/try.rb
picky-3.6.15 lib/tasks/try.rb
picky-3.6.14 lib/tasks/try.rb
picky-3.6.13 lib/tasks/try.rb
picky-3.6.12 lib/tasks/try.rb
picky-3.6.11 lib/tasks/try.rb
picky-3.6.10 lib/tasks/try.rb
picky-3.6.9 lib/tasks/try.rb
picky-3.6.8 lib/tasks/try.rb
picky-3.6.7 lib/tasks/try.rb
picky-3.6.6 lib/tasks/try.rb
picky-3.6.4 lib/tasks/try.rb
picky-3.6.3 lib/tasks/try.rb
picky-3.6.2 lib/tasks/try.rb
picky-3.6.1 lib/tasks/try.rb
picky-3.6.0 lib/tasks/try.rb
picky-3.5.4 lib/tasks/try.rb
picky-3.5.3 lib/tasks/try.rb
picky-3.5.2 lib/tasks/try.rb