class Squib::Args::InputFile

Public Class Methods

expanding_parameters() click to toggle source
# File lib/squib/args/input_file.rb, line 22
def self.expanding_parameters
  parameters.keys # all of them
end
new(dsl_method_default = {}) click to toggle source
# File lib/squib/args/input_file.rb, line 11
def initialize(dsl_method_default = {})
  @dsl_method_default = dsl_method_default
end
parameters() click to toggle source
# File lib/squib/args/input_file.rb, line 15
def self.parameters
  {
    file: nil,
    placeholder: nil
  }
end
params_with_units() click to toggle source
# File lib/squib/args/input_file.rb, line 26
def self.params_with_units
  [] # none of them
end

Public Instance Methods

validate_file(arg, i) click to toggle source
# File lib/squib/args/input_file.rb, line 30
def validate_file(arg, i)
  return nil if arg.nil?
  return File.expand_path(arg) if File.exists?(arg)
  return File.expand_path(placeholder[i]) if File.exists?(placeholder[i].to_s)

  case deck_conf.img_missing.to_sym
  when :error
    raise "File #{File.expand_path(arg)} does not exist!"
  when :warn
    Squib.logger.warn "File #{File.expand_path(arg)} does not exist!"
  end
  return nil # the silent option - as if nil in the first place
end
validate_placeholder(arg, _i) click to toggle source
# File lib/squib/args/input_file.rb, line 44
def validate_placeholder(arg, _i)
  # What if they specify placeholder, but it doesn't exist?
  # ...always warn... that's probably a mistake they made
  unless arg.nil? || File.exists?(arg)
    msg = "Image placeholder #{File.expand_path(arg)} does not exist!"
    Squib.logger.warn msg
    return nil
  end
  return arg
end