Class: Procreate::Swatches::Parser

Inherits:
Object
  • Object
show all
Includes:
CallableClass, ColorsHelper
Defined in:
lib/procreate/swatches/parser.rb

Overview

The class that handles the parsing of a .swatches file to an instance of Wrapper.

Constant Summary

Constants included from ColorsHelper

ColorsHelper::SELECTED_KEYS, ColorsHelper::SWATCHES_ALPHA, ColorsHelper::SWATCHES_COLOR_SPACE, ColorsHelper::SWATCHES_MAX_SIZE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ColorsHelper

#prepare_color_for_push, #to_chroma_hsv, #to_color_json, #to_swatches_json

Constructor Details

#initialize(file_path) ⇒ Parser

Initialize a new instance of Procreate::Swatches::Parser

Parameters:

  • file_path (String)

    The path of the .swatches file

Raises:



35
36
37
38
39
# File 'lib/procreate/swatches/parser.rb', line 35

def initialize(file_path)
  @file_path = file_path

  validate!
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



25
26
27
# File 'lib/procreate/swatches/parser.rb', line 25

def file_path
  @file_path
end

#wrapperObject (readonly)

Returns the value of attribute wrapper.



21
22
23
# File 'lib/procreate/swatches/parser.rb', line 21

def wrapper
  @wrapper
end

Class Method Details

.callObject

Creates a new instance of Procreate::Swatches::Parser and calls #call Dynamically included by using CallableClass gem.



# File 'lib/procreate/swatches/parser.rb', line 15

Instance Method Details

#callProcreate::Swatches::Wrapper

Process the provided .swatches file and wrap the content in a Wrapper

Returns:



47
48
49
50
# File 'lib/procreate/swatches/parser.rb', line 47

def call
  unzip
  wrap_colors
end