class ColorPlistGenerator
Attributes
base_path[R]
plist_hash[R]
prefix[R]
Public Class Methods
new(plist_hash, prefix, base_path)
click to toggle source
# File lib/KMQToolKitGem/color_plist_generator.rb, line 7 def initialize(plist_hash, prefix, base_path) @template_folder = File.expand_path('../../templates', __FILE__) @plist_hash = plist_hash @prefix = prefix @base_path = base_path check end
Public Instance Methods
check()
click to toggle source
# File lib/KMQToolKitGem/color_plist_generator.rb, line 31 def check if !@plist_hash.is_a?(Hash) raise RuntimeError, "Invalid plist format" end end
create_color_name_file(names, type)
click to toggle source
# File lib/KMQToolKitGem/color_plist_generator.rb, line 23 def create_color_name_file(names, type) file_name = "UIColor+#{@prefix}ColorName.#{type}" template_path = "#{@template_folder}/UIColor+ColorName.#{type}.erb" absolute_file_path = "#{@base_path}/#{file_name}" variables = OpenStruct.new(names: names, prefix: @prefix) Helper.write_to_file(absolute_file_path, template_path, variables.instance_eval{ binding }) end
generate_color_names()
click to toggle source
# File lib/KMQToolKitGem/color_plist_generator.rb, line 15 def generate_color_names color_names = @plist_hash.keys.collect do |name| name.slice(0, 1).capitalize + name.slice(1..-1) end create_color_name_file(color_names, 'h') create_color_name_file(color_names, 'm') end