Module: Emojidex::Data::EmojiComponentSetAssetInformation
- Included in:
- ComponentSet
- Defined in:
- lib/emojidex/data/emoji/component_set_asset_information.rb
Overview
Asset information for emoji
Instance Attribute Summary collapse
-
#checksums ⇒ Object
Returns the value of attribute checksums.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#remote_checksums ⇒ Object
Returns the value of attribute remote_checksums.
Instance Method Summary collapse
- #blank_checksums ⇒ Object
- #blank_paths ⇒ Object
- #fill_paths(paths) ⇒ Object
- #fill_remote_checksums(checksums) ⇒ Object
- #generate_blank_entry_set ⇒ Object
- #generate_blank_path_set ⇒ Object
- #generate_checksum(component_set_num, component_name, format, size = nil) ⇒ Object
- #generate_checksums ⇒ Object
- #init_asset_info(details = {}) ⇒ Object
Instance Attribute Details
#checksums ⇒ Object
Returns the value of attribute checksums.
8 9 10 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 8 def checksums @checksums end |
#paths ⇒ Object
Returns the value of attribute paths.
8 9 10 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 8 def paths @paths end |
#remote_checksums ⇒ Object
Returns the value of attribute remote_checksums.
8 9 10 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 8 def remote_checksums @remote_checksums end |
Instance Method Details
#blank_checksums ⇒ Object
54 55 56 57 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 54 def blank_checksums @checksums = generate_blank_entry_set @remote_checksums = generate_blank_entry_set end |
#blank_paths ⇒ Object
34 35 36 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 34 def blank_paths @paths = generate_blank_path_set end |
#fill_paths(paths) ⇒ Object
48 49 50 51 52 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 48 def fill_paths(paths) @paths = paths @paths[:svg].slice!(/\.svg$/) @paths[:png].each { |png| png.slice!(/\.png$/) } end |
#fill_remote_checksums(checksums) ⇒ Object
82 83 84 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 82 def fill_remote_checksums(checksums) #todo once implemented in API end |
#generate_blank_entry_set ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/emojidex/data/emoji/component_set_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| next if 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_set ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 38 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
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 59 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_checksums ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/emojidex/data/emoji/component_set_asset_information.rb', line 71 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/component_set_asset_information.rb', line 10 def init_asset_info(details = {}) blank_paths blank_checksums fill_remote_checksums(details[:checksums]) if details.include? :checksums end |