Class: RubySpriter::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_spriter/processor.rb

Overview

Main orchestration processor

Constant Summary collapse

VALID_RANGES =

Valid ranges for numeric options

{
  frame_count: { min: 1, max: 10000, type: Integer },
  columns: { min: 1, max: 100, type: Integer },
  max_width: { min: 1, max: 1920, type: Integer },
  scale_percent: { min: 1, max: 500, type: Integer },
  grow_selection: { min: 0, max: 100, type: Integer },
  sharpen_radius: { min: 0.1, max: 100.0, type: Float },
  sharpen_gain: { min: 0.0, max: 10.0, type: Float },
  sharpen_threshold: { min: 0.0, max: 1.0, type: Float },
  bg_threshold: { min: 0.0, max: 100.0, type: Float }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Processor

Returns a new instance of Processor.



25
26
27
28
29
30
31
32
33
# File 'lib/ruby_spriter/processor.rb', line 25

def initialize(options = {})
  @options = default_options.merge(options)
  @gimp_path = nil
  @gimp_version = nil
  validate_numeric_options!
  validate_split_option!
  validate_extract_option!
  validate_add_meta_option!
end

Instance Attribute Details

#gimp_pathObject (readonly)

Returns the value of attribute gimp_path.



10
11
12
# File 'lib/ruby_spriter/processor.rb', line 10

def gimp_path
  @gimp_path
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/ruby_spriter/processor.rb', line 10

def options
  @options
end

#split_columnsObject (readonly)

Returns the value of attribute split_columns.



10
11
12
# File 'lib/ruby_spriter/processor.rb', line 10

def split_columns
  @split_columns
end

#split_rowsObject (readonly)

Returns the value of attribute split_rows.



10
11
12
# File 'lib/ruby_spriter/processor.rb', line 10

def split_rows
  @split_rows
end

Instance Method Details

#runObject

Run the processing workflow



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby_spriter/processor.rb', line 36

def run
  validate_options!
  check_dependencies!
  setup_temp_directory

  result = execute_workflow

  cleanup unless options[:keep_temp]

  result
end