Class: Droonga::Catalog::VolumeCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/droonga/catalog/volume_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(volumes) ⇒ VolumeCollection

Returns a new instance of VolumeCollection.



21
22
23
# File 'lib/droonga/catalog/volume_collection.rb', line 21

def initialize(volumes)
  @volumes = volumes
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
# File 'lib/droonga/catalog/volume_collection.rb', line 29

def ==(other)
  other.is_a?(self.class) and
    to_a == other.to_a
end

#each(&block) ⇒ Object



25
26
27
# File 'lib/droonga/catalog/volume_collection.rb', line 25

def each(&block)
  @volumes.each(&block)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/droonga/catalog/volume_collection.rb', line 34

def eql?(other)
  self == other
end

#hashObject



38
39
40
# File 'lib/droonga/catalog/volume_collection.rb', line 38

def hash
  to_a.hash
end

#select(how = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/droonga/catalog/volume_collection.rb', line 42

def select(how=nil)
  case how
  when :top
    [@volumes.first]
  when :random
    [@volumes.sample]
  when :all
    @volumes
  else
    super
  end
end