Class: Emojidex::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/emojidex/client.rb

Overview

A consolidated client which handles a user and their collection

Constant Summary collapse

@@client_cache_path =
nil
@@user_instance =
nil
@@collection_instance =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



44
45
46
47
48
49
50
51
# File 'lib/emojidex/client.rb', line 44

def initialize(opts = {})
  if (opts.include? :cache_path)
    @@client_cache_path = opts[:cache_path]
    user = collection = nil
  end
  user
  collection
end

Class Method Details

.CACHE_PATHObject



34
35
36
37
38
# File 'lib/emojidex/client.rb', line 34

def self.CACHE_PATH
  return @@client_cache_path unless @@client_cache_path.nil?
  @@client_cache_path = Emojidex::Defaults.system_cache_path
  @@client_cache_path
end

.COLLECTIONObject



23
24
25
26
27
28
# File 'lib/emojidex/client.rb', line 23

def self.COLLECTION
  return @@collection_instance unless @@collection_instance.nil?
  @@collection_instance = Emojidex::Data::Collection.new
  @@collection_instance.load_cache
  @@collection_instance
end

.USERObject



12
13
14
15
16
17
# File 'lib/emojidex/client.rb', line 12

def self.USER
  return @@user_instance unless @@user_instance.nil?
  @@user_instance = Emojidex::Service::User.new
  @@user_instance.load(@cache_path)
  @@user_instance
end

Instance Method Details

#cache_pathObject



40
41
42
# File 'lib/emojidex/client.rb', line 40

def cache_path
  Emojidex::Client.CACHE_PATH
end

#collectionObject



30
31
32
# File 'lib/emojidex/client.rb', line 30

def collection
  Emojidex::Client.COLLECTION
end

#userObject



19
20
21
# File 'lib/emojidex/client.rb', line 19

def user
  Emojidex::Client.USER
end