Class: Procreate::Swatches::Exporter

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

Overview

The class that handles the export of a Wrapper to a .swatches file.

Constant Summary collapse

PERMITTED_OPTIONS =

Permitted options. Any other key will be discarded.

%i[export_directory file_name].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrapper, options = {}) ⇒ Exporter

Parameters:

Options Hash (options):

  • :export_directory (String) — default: 'Dir.pwd'

    The export directory for the .swatches file

  • :file_name (String) — default: 'Wrapper#name'

    Custom file name for the exported .swatches file. If none is provided, the name of the wrapper instance is used



32
33
34
35
# File 'lib/procreate/swatches/exporter.rb', line 32

def initialize(wrapper, options = {})
  @wrapper = wrapper
  parse_options(options)
end

Instance Attribute Details

#optionsHash

Export options

Returns:

  • (Hash)

    Export options



51
52
53
# File 'lib/procreate/swatches/exporter.rb', line 51

def options
  parse_options(@options)
end

#swatches_pathObject (readonly)

The computed path of the .swatches file, after the file was exported.



22
23
24
# File 'lib/procreate/swatches/exporter.rb', line 22

def swatches_path
  @swatches_path
end

#wrapperObject

An instance of Wrapper



20
21
22
# File 'lib/procreate/swatches/exporter.rb', line 20

def wrapper
  @wrapper
end

Class Method Details

.callObject

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



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

Instance Method Details

#callString Also known as: export

Exports the .swatches file.

Returns:

  • (String)

    swatches_path Path of the exported .swatches file



40
41
42
43
44
# File 'lib/procreate/swatches/exporter.rb', line 40

def call
  zip_content!

  swatches_path
end