Class: A4Tools::KaiConfigClient

Inherits:
CachingClient show all
Defined in:
lib/clients/kai_config_client.rb

Instance Attribute Summary collapse

Attributes inherited from CachingClient

#timeout

Attributes inherited from AcresClient

#connect_time, #connected, #history, #password, #ready, #server_info, #start_time, #token, #uri, #username, #version

Instance Method Summary collapse

Methods inherited from CachingClient

#[], cache, #cache, #dirty, #ensure_fresh, #fresh?, #initialize, #query, query, #refresh, #refresh_async, #send_update_request, #timestamp_expired?, #update_from_method

Methods inherited from AcresClient

#add_message_to_history, #app_info, #attempt_snoop, #authenticate, #authenticate_if_needed, #connect, #connect_if_needed, #device_info, #disconnect, #empty_query, #initialize, #inject_token, #jsonrpc_message, #make_password, #next_msg_id, #response_body, #send_message, #snoop_token, #transport_connect, #wrapped_message

Methods included from EventGenerator

#on, #passthrough, #signal

Constructor Details

This class inherits a constructor from A4Tools::CachingClient

Instance Attribute Details

#cache_timeoutObject

Returns the value of attribute cache_timeout.



3
4
5
# File 'lib/clients/kai_config_client.rb', line 3

def cache_timeout
  @cache_timeout
end

Instance Method Details

#banksObject



35
36
37
# File 'lib/clients/kai_config_client.rb', line 35

def banks
  (section_bank_info[:banks].map { |bank| bank[:bankName] })
end

#machinesObject



27
28
29
# File 'lib/clients/kai_config_client.rb', line 27

def machines
  (section_bank_info[:locations].map { |loc| loc[:location] })
end

#section_bank_infoObject



23
24
25
# File 'lib/clients/kai_config_client.rb', line 23

def section_bank_info
  strip_wrapper(query(:configValueRequest, talk["SECTION_BANK_LOCATION_VALUES"]))
end

#sectionsObject



31
32
33
# File 'lib/clients/kai_config_client.rb', line 31

def sections
  (section_bank_info[:sections].map { |sect| sect[:sectionName] })
end

#site_versionObject



19
20
21
# File 'lib/clients/kai_config_client.rb', line 19

def site_version
  response_body(send_message(empty_query(:getConfigWebVersion)))[:stringValue] rescue nil
end

#strip_wrapper(result) ⇒ Object



13
14
15
16
17
# File 'lib/clients/kai_config_client.rb', line 13

def strip_wrapper(result)
  body = result[:configValueWrappers][0][:wrappedConfigValues][0][:body]
  body[:__class] = result[:configValueWrappers][0][:wrappedConfigValues][0][:className]
  body
end