Module: Emojidex::Data::CollectionAssetInformation

Included in:
Collection, CollectionCache
Defined in:
lib/emojidex/data/collection/asset_information.rb

Overview

Asset Information for Collections

Instance Method Summary collapse

Instance Method Details

#generate_checksums(formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes) ⇒ Object



8
9
10
11
12
13
# File 'lib/emojidex/data/collection/asset_information.rb', line 8

def generate_checksums(formats = Emojidex::Defaults.formats,
                       sizes = Emojidex::Defaults.sizes)
  @emoji.values.each do |moji|
    moji.checksums = get_checksums(moji, formats, sizes)
  end
end

#generate_paths(formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes) ⇒ Object



28
29
30
31
32
# File 'lib/emojidex/data/collection/asset_information.rb', line 28

def generate_paths(formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes)
  @emoji.values.each do |moji|
    moji.paths = get_paths(moji, formats, sizes)
  end
end

#get_checksums(moji, formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/emojidex/data/collection/asset_information.rb', line 15

def get_checksums(moji, formats = Emojidex::Defaults.formats,
                  sizes = Emojidex::Defaults.sizes)
  sums = {}
  sums[:svg] = _checksum_for_file("#{@vector_source_path}/#{moji.code}.svg") if formats.include? :svg
  if formats.include? :png
    sums[:png] = {}
    sizes.keys.each do |size|
      sums[:png][size] = _checksum_for_file("#{@raster_source_path}/#{size}/#{moji.code}.png")
    end
  end
  sums
end

#get_paths(moji, formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/emojidex/data/collection/asset_information.rb', line 48

def get_paths(moji, formats = Emojidex::Defaults.formats,
              sizes = Emojidex::Defaults.sizes)
  paths = {}
  paths[:svg] = "#{@vector_source_path}/#{moji.code}.svg"
  if formats.include? :png
    paths[:png] = {}
    sizes.keys.each do |size|
      paths[:png][size] = "#{@raster_source_path}/#{size}/#{moji.code}.png"
    end
  end
  paths
end

#get_paths?(moji, formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/emojidex/data/collection/asset_information.rb', line 34

def get_paths?(moji, formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes)
  paths = {}
  path = "#{@vector_source_path}/#{moji.code}.svg"
  paths[:svg] = path if File.exist? path
  if formats.include? :png
    paths[:png] = {}
    sizes.keys.each do |size|
      path = "#{@raster_source_path}/#{size}/#{moji.code}.png"
      paths[:png][size] = path if File.exist? path
    end
  end
  paths
end