Class: StartsWithLetter

Inherits:
Natural::Fragment show all
Defined in:
lib/natural/fragments/example.rb

Overview

e.g. start with the letter t

Instance Attribute Summary

Attributes inherited from Natural::Fragment

#aggregator, #score, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Natural::Fragment

#all_filters, #clone, #data, #id_range, #ids, #ids=, #initialize, #pretty_to_s, recurse_alternatives, #to_s

Constructor Details

This class inherits a constructor from Natural::Fragment

Class Method Details

.find(options) ⇒ Object



32
33
34
# File 'lib/natural/fragments/example.rb', line 32

def self.find(options)
  super options.merge(:looking_for => {:and => ['start with the letter', {:or => ('a'..'z').to_a}]})
end

Instance Method Details

#filterObject



35
36
37
# File 'lib/natural/fragments/example.rb', line 35

def filter
  "select {|a| a[0].downcase == '#{self.children.last.to_s.downcase}'}"
end