Class: Couchbase::SearchRowLocations

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/search_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(locations) ⇒ SearchRowLocations



1429
1430
1431
1432
# File 'lib/couchbase/search_options.rb', line 1429

def initialize(locations)
  super()
  @locations = locations
end

Instance Method Details

#fieldsArray<String>

Lists the fields in this location



1410
1411
1412
# File 'lib/couchbase/search_options.rb', line 1410

def fields
  @locations.map(&:field).uniq
end

#get_allArray<SearchRowLocation>

Lists all locations (any field, any term)



1389
1390
1391
# File 'lib/couchbase/search_options.rb', line 1389

def get_all
  @locations
end

#get_for_field(name) ⇒ Array<SearchRowLocation>

Lists all locations for a given field (any term)



1396
1397
1398
# File 'lib/couchbase/search_options.rb', line 1396

def get_for_field(name)
  @locations.select { |location| location.field == name }
end

#get_for_field_and_term(name, term) ⇒ Array<SearchRowLocation>

Lists all locations for a given field and term



1403
1404
1405
# File 'lib/couchbase/search_options.rb', line 1403

def get_for_field_and_term(name, term)
  @locations.select { |location| location.field == name && location.term == term }
end

#termsArray<String>

Lists all terms in this locations, considering all fields



1417
1418
1419
# File 'lib/couchbase/search_options.rb', line 1417

def terms
  @locations.map(&:term).uniq
end

#terms_for_field(name) ⇒ Array<String>

Lists the terms for a given field



1424
1425
1426
# File 'lib/couchbase/search_options.rb', line 1424

def terms_for_field(name)
  get_for_field(name).map(&:term).uniq
end