Class: Desi::IndexManager::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/desi/index_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, state_data, status_data) ⇒ Index

Returns a new instance of Index.



15
16
17
18
19
20
21
22
23
24
# File 'lib/desi/index_manager.rb', line 15

def initialize(name, state_data, status_data)
  @name = name
  @number_of_documents = status_data["docs"]["num_docs"] if status_data && status_data["docs"]
  @aliases = []

  if state_data
    @aliases = state_data['aliases']
    @state = state_data['state']
  end
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



13
14
15
# File 'lib/desi/index_manager.rb', line 13

def aliases
  @aliases
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/desi/index_manager.rb', line 13

def name
  @name
end

#number_of_documentsObject (readonly)

Returns the value of attribute number_of_documents.



13
14
15
# File 'lib/desi/index_manager.rb', line 13

def number_of_documents
  @number_of_documents
end

#stateObject (readonly)

Returns the value of attribute state.



13
14
15
# File 'lib/desi/index_manager.rb', line 13

def state
  @state
end

Instance Method Details

#<=>(other) ⇒ Object



38
39
40
# File 'lib/desi/index_manager.rb', line 38

def <=>(other)
  name <=> other.name
end

#aliased?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/desi/index_manager.rb', line 34

def aliased?
  !(aliases.nil? || aliases.empty?)
end

#closed?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/desi/index_manager.rb', line 46

def closed?
  state == "close"
end

#inspectObject



30
31
32
# File 'lib/desi/index_manager.rb', line 30

def inspect
  "#{name} (#{number_of_docs_label})#{aliases_label}"
end

#open?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/desi/index_manager.rb', line 42

def open?
  state == "open"
end

#to_sObject



26
27
28
# File 'lib/desi/index_manager.rb', line 26

def to_s
  name
end