Class: Ej::Values

Inherits:
Object
  • Object
show all
Defined in:
lib/ej/values.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(global_options) ⇒ Values

Returns a new instance of Values.



7
8
9
10
11
12
# File 'lib/ej/values.rb', line 7

def initialize(global_options)
  @logger =  Logger.new($stderr)
  @logger.level = global_options[:debug] ? Logger::DEBUG : Logger::INFO
  @client = get_client(global_options[:host], global_options[:index], global_options[:user], global_options[:password])
  @index = global_options[:index]
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/ej/values.rb', line 3

def client
  @client
end

#indexObject (readonly)

Returns the value of attribute index.



4
5
6
# File 'lib/ej/values.rb', line 4

def index
  @index
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/ej/values.rb', line 5

def logger
  @logger
end

Instance Method Details

#get_client(host_string, index, user, password) ⇒ Object



14
15
16
17
# File 'lib/ej/values.rb', line 14

def get_client(host_string, index, user, password)
  hosts = Util.parse_hosts(host_string, user, password)
  ::Elasticsearch::Client.new transport: Util.get_transport(hosts), index: index, logger: @logger
end