Class: Unfig::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/unfig/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(values:, argv: UNSUPPLIED, env: UNSUPPLIED, config: UNSUPPLIED, **options) ⇒ Loader

Returns a new instance of Loader.



3
4
5
6
7
8
9
10
# File 'lib/unfig/loader.rb', line 3

def initialize(values:, argv: UNSUPPLIED, env: UNSUPPLIED, config: UNSUPPLIED, **options)
  @argv = argv
  @env = env
  @config = config
  @values = values
  @format = options.fetch(:format, :hash)
  @banner = options.fetch(:banner, nil)
end

Instance Method Details

#readObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/unfig/loader.rb', line 12

def read
  @_read ||=
    case format.to_s
    when "hash" then hashed_values
    when "struct" then struct_values
    when "openstruct" then openstruct_values
    else
      raise ArgumentError, "Unfig::Loader cannot return results in the format '#{format}'"
    end
end