Class: Flock::SelectOperation

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Mixins::Sizeable
Defined in:
lib/flock/operations/select_operation.rb

Direct Known Subclasses

ComplexOperation, SimpleOperation

Instance Method Summary collapse

Methods included from Mixins::Sizeable

#any?, #empty?

Constructor Details

#initialize(client) ⇒ SelectOperation

Returns a new instance of SelectOperation.



10
11
12
13
# File 'lib/flock/operations/select_operation.rb', line 10

def initialize(client)
  @client = client
  @service = client.service
end

Instance Method Details

#difference(*args) ⇒ Object



25
26
27
28
# File 'lib/flock/operations/select_operation.rb', line 25

def difference(*args)
  other = _operation_from_args(args)
  ComplexOperation.new(@client, Edges::SelectOperationType::Difference, self, other)
end

#get_results(page) ⇒ Object



30
31
32
# File 'lib/flock/operations/select_operation.rb', line 30

def get_results(page)
  @service.select(to_thrift, page)
end

#intersect(*args) ⇒ Object



15
16
17
18
# File 'lib/flock/operations/select_operation.rb', line 15

def intersect(*args)
  other = _operation_from_args(args)
  ComplexOperation.new(@client, Edges::SelectOperationType::Intersection, self, other)
end

#operationObject



38
39
40
41
42
43
# File 'lib/flock/operations/select_operation.rb', line 38

def operation
  Flock::Operation.new do |page|
    results = get_results(page)
    [results.ids.unpack("Q*"), results.next_cursor, results.prev_cursor]
  end
end

#sizeObject



34
35
36
# File 'lib/flock/operations/select_operation.rb', line 34

def size
  @service.count(to_thrift)
end

#union(*args) ⇒ Object



20
21
22
23
# File 'lib/flock/operations/select_operation.rb', line 20

def union(*args)
  other = _operation_from_args(args)
  ComplexOperation.new(@client, Edges::SelectOperationType::Union, self, other)
end