Module: Emojidex::Data::EmojiCombinationAssetInformation

Included in:
Combination
Defined in:
lib/emojidex/data/emoji/combination_asset_information.rb

Overview

Asset information for emoji

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#checksumsObject

Returns the value of attribute checksums.



8
9
10
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 8

def checksums
  @checksums
end

#pathsObject

Returns the value of attribute paths.



8
9
10
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 8

def paths
  @paths
end

#remote_checksumsObject

Returns the value of attribute remote_checksums.



8
9
10
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 8

def remote_checksums
  @remote_checksums
end

Instance Method Details

#blank_checksumsObject



53
54
55
56
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 53

def blank_checksums
  @checksums = generate_blank_entry_set
  @remote_checksums = generate_blank_entry_set
end

#blank_pathsObject



33
34
35
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 33

def blank_paths
  @paths = generate_blank_path_set
end

#fill_paths(paths) ⇒ Object



47
48
49
50
51
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 47

def fill_paths(paths)
  @paths = paths
  @paths[:svg].slice!(/\.svg$/)
  @paths[:png].each { |png| png.slice!(/\.png$/) }
end

#fill_remote_checksums(checksums) ⇒ Object



81
82
83
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 81

def fill_remote_checksums(checksums)
  #todo once implemented in API
end

#generate_blank_entry_setObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 16

def generate_blank_entry_set
  entry_set = []
  @components.each do |component_set|
    component_group = {}
    component_set.each do |single_component|
      component_group[single_component] = {}
      component_group[single_component][:svg] = nil
      component_group[single_component][:png] = {}
      Emojidex::Defaults.sizes.keys.each do |size|
        component_group[single_component][:png][size] = nil
      end
    end
    entry_set << component_group
  end
  entry_set
end

#generate_blank_path_setObject



37
38
39
40
41
42
43
44
45
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 37

def generate_blank_path_set
  paths = {}
  paths[:svg] = nil
  paths[:png] = {}
  Emojidex::Defaults.sizes.keys.each do |size|
    paths[:png][size] = nil
  end
  paths
end

#generate_checksum(component_set_num, component_name, format, size = nil) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 58

def generate_checksum(component_set_num, component_name, format, size = nil)
  case format
  when :png
    return @checksums[component_set_num][component_name][:png][size] =
      _checksum_for_file("#{@paths[:png][size]}/#{component_set_num}/#{component_name}.png")
  when :svg
    return @checksums[component_set_num][component_name][:svg] =
      _checksum_for_file("#{@paths[:svg]}/#{component_set_num}/#{component_name}.svg")
  end
  nil
end

#generate_checksumsObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 70

def generate_checksums
  @components.each_with_index do |component_set, i|
    component_set.each do |component_name|
      generate_checksum(i, component_name, :svg)
      @checksums[i][component_name][:png].keys.each do |size_key|
        generate_checksum(i, component_name, :png, size_key)
      end
    end
  end
end

#init_asset_info(details = {}) ⇒ Object



10
11
12
13
14
# File 'lib/emojidex/data/emoji/combination_asset_information.rb', line 10

def init_asset_info(details = {})
  blank_paths
  blank_checksums
  fill_remote_checksums(details[:checksums]) if details.include? :checksums
end