Class: Lit::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/lit/import.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input:, format:, locale_keys: [], skip_nil: true, dry_run: false, raw: false) ⇒ Import

Returns a new instance of Import.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
# File 'lib/lit/import.rb', line 13

def initialize(input:, format:, locale_keys: [], skip_nil: true, dry_run: false, raw: false)
  raise ArgumentError, 'format must be yaml or csv' if %i[yaml csv].exclude?(format.to_sym)
  @input = input
  @locale_keys = locale_keys.presence || I18n.available_locales
  @format = format
  @skip_nil = skip_nil
  @dry_run = dry_run
  @raw = raw
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



11
12
13
# File 'lib/lit/import.rb', line 11

def format
  @format
end

#inputObject (readonly)

Returns the value of attribute input.



11
12
13
# File 'lib/lit/import.rb', line 11

def input
  @input
end

#locale_keysObject (readonly)

Returns the value of attribute locale_keys.



11
12
13
# File 'lib/lit/import.rb', line 11

def locale_keys
  @locale_keys
end

#skip_nilObject (readonly)

Returns the value of attribute skip_nil.



11
12
13
# File 'lib/lit/import.rb', line 11

def skip_nil
  @skip_nil
end

Class Method Details

.call(**kwargs) ⇒ Object



6
7
8
# File 'lib/lit/import.rb', line 6

def call(**kwargs)
  new(**kwargs).perform
end

Instance Method Details

#performObject



23
24
25
# File 'lib/lit/import.rb', line 23

def perform
  send(:"import_#{format}")
end