Module: Emojidex::Data::StaticCollection

Included in:
Extended, UTF
Defined in:
lib/emojidex/data/collection/static_collection.rb

Overview

mixin module to enable static collections

Instance Method Summary collapse

Instance Method Details

#check_and_load_static(collection) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/emojidex/data/collection/static_collection.rb', line 19

def check_and_load_static(collection)
  loaded = false
  if defined? Emojidex::Vectors
    @vector_source_path = Emojidex::Vectors.path + "/#{collection}/"
    load_local_collection @vector_source_path
    loaded = true
  end
  if defined? Emojidex::Rasters
    @raster_source_path = Emojidex::Rasters.path + "/#{collection}/"
    load_local_collection @raster_source_path
    loaded = true
  end
  loaded
end

#load_from_server(detailed = true, locale = '??') ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/emojidex/data/collection/static_collection.rb', line 8

def load_from_server(detailed = true, locale = '??')
  locale = @locale || Emojidex::EnvHelper.lang? if locale == '??'
  begin
    res = Emojidex::Service::Transactor.get(@endpoint, detailed: detailed, locale: locale)
  rescue
    false
  end
  add_emoji(res)
  true
end