Class: Squib::Args::SaveBatch

Inherits:
Object
  • Object
show all
Includes:
ArgLoader, DirValidator
Defined in:
lib/squib/args/save_batch.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DirValidator

#ensure_dir_created

Methods included from ArgLoader

#[], #convert_units, #deck_conf, #defaultify, #expand_and_set_and_defaultify, #expandable_singleton?, #extract!, #load!, #prep_layout_args, #validate

Constructor Details

#initializeSaveBatch

Returns a new instance of SaveBatch.



13
14
# File 'lib/squib/args/save_batch.rb', line 13

def initialize
end

Class Method Details

.expanding_parametersObject



29
30
31
# File 'lib/squib/args/save_batch.rb', line 29

def self.expanding_parameters
  self.parameters.keys # all of them
end

.parametersObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/squib/args/save_batch.rb', line 16

def self.parameters
  {
    angle: 0,
    count_format: '%02d',
    dir: '_output',
    prefix: 'card_',
    rotate: false,
    suffix: '',
    trim_radius: 0,
    trim: 0,
  }
end

.params_with_unitsObject



33
34
35
# File 'lib/squib/args/save_batch.rb', line 33

def self.params_with_units
  [:trim, :trim_radius]
end

Instance Method Details

#full_filename(i) ⇒ Object



56
57
58
# File 'lib/squib/args/save_batch.rb', line 56

def full_filename(i)
  "#{dir[i]}/#{prefix[i]}#{count_format[i] % i}#{suffix[i]}.png"
end

#summaryObject



60
61
62
# File 'lib/squib/args/save_batch.rb', line 60

def summary
  "#{dir[0]}/#{prefix[0]}_*#{suffix[0]}"
end

#validate_dir(arg, _i) ⇒ Object



37
38
39
# File 'lib/squib/args/save_batch.rb', line 37

def validate_dir(arg, _i)
  ensure_dir_created(arg)
end

#validate_rotate(arg, i) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/squib/args/save_batch.rb', line 41

def validate_rotate(arg, i)
  case arg
  when true, :clockwise
    angle[i] = 0.5 * Math::PI
    return true
  when :counterclockwise
    angle[i] = 1.5 * Math::PI
    return true
  when false
    false
  else
    raise 'invalid option to rotate: only [true, false, :clockwise, :counterclockwise]'
  end
end