Class: Seasy::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/seasy/index.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = 'default') ⇒ Index

Returns a new instance of Index.



23
24
25
26
27
# File 'lib/seasy/index.rb', line 23

def initialize name = 'default'
  @name = name
  @storage = Configuration.instance.storage.new
  @storage.name = name if @storage.respond_to? :name=
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/seasy/index.rb', line 21

def name
  @name
end

Class Method Details

.defaultObject



29
30
31
# File 'lib/seasy/index.rb', line 29

def Index::default
  @@defaultee = Index.new if not defined? @@defaultee
end

.with_name(name) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/seasy/index.rb', line 33

def Index::with_name name
  stringed_name = name.to_s
  @@indices = {} if not defined? @@indices
  if @@indices[stringed_name].nil?
    @@indices[stringed_name] = Index.new stringed_name
  end
  @@indices[stringed_name]
end

Instance Method Details

#add(searchee, target, options = {}) ⇒ Object



42
43
44
45
# File 'lib/seasy/index.rb', line 42

def add searchee, target, options = {}
  options[:source] = target if options[:source].nil?
  save target, fragmentize( searchee ), options
end

#clearObject



51
52
53
# File 'lib/seasy/index.rb', line 51

def clear
  @storage.clear
end

#remove(target) ⇒ Object



55
56
57
# File 'lib/seasy/index.rb', line 55

def remove target
  @storage.remove target
end

#search(query) ⇒ Object



47
48
49
# File 'lib/seasy/index.rb', line 47

def search query
  @storage.search query.downcase
end