Module: OutwoodLabels

Defined in:
lib/outwood_labels.rb,
lib/outwood_labels/cli.rb,
lib/outwood_labels/options.rb,
lib/outwood_labels/version.rb,
lib/outwood_labels/callable.rb,
lib/outwood_labels/generate.rb,
lib/outwood_labels/template.rb,
lib/outwood_labels/csv_loader.rb,
lib/outwood_labels/file_namer.rb,
lib/outwood_labels/template/base.rb,
lib/outwood_labels/options_validator.rb,
lib/outwood_labels/template/email_password.rb,
lib/outwood_labels/template/email_password_initial.rb

Defined Under Namespace

Modules: Callable, Template Classes: CLI, CsvLoader, Error, FileNamer, Generate, OptionArgumentError, Options, OptionsValidator

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Parameters:

  • name (String)

    name of a template



20
21
22
# File 'lib/outwood_labels.rb', line 20

def self.[](name)
  default_mapping[name]
end

.default_mapping{String => Template::Base}

Returns:



34
35
36
# File 'lib/outwood_labels.rb', line 34

def self.default_mapping
  @templates
end

.infer_template(columns = []) ⇒ Template::Base?

Parameters:

  • columns (Array<String>) (defaults to: [])

    list of column names

Returns:



26
27
28
29
30
31
# File 'lib/outwood_labels.rb', line 26

def self.infer_template(columns = [])
  default_mapping.each_value.reverse_each do |t|
    return t if t.valid_for? columns
  end
  nil
end

.register(klass) ⇒ Object

Parameters:

  • klass (Class)

    template class to add



15
16
17
# File 'lib/outwood_labels.rb', line 15

def self.register(klass)
  default_mapping[klass.name] = klass
end