class Photein::Config
Constants
- OPTIONS
- OPTION_NAMES
Public Class Methods
[](key)
click to toggle source
# File lib/photein/config.rb, line 52 def [](key) @params[key] end
method_missing(m, *args, &blk)
click to toggle source
Calls superclass method
# File lib/photein/config.rb, line 56 def method_missing(m, *args, &blk) m.to_s.tr('_', '-').to_sym .then { |key| OPTION_NAMES.include?(key) ? self[key] : super } end
parse_opts!()
click to toggle source
# File lib/photein/config.rb, line 29 def parse_opts! @params = {} parser = OptionParser.new do |opts| opts.version = Photein::VERSION opts.banner = <<~BANNER Usage: photein [--version] [-h | --help] [<args>] BANNER OPTIONS.each { |opt| opts.on(*opt) } end.tap { |p| p.parse!(into: @params) } @params[:verbose] ||= @params[:'dry-run'] @params.freeze raise "no source directory given" if !@params.key?(:source) raise "no destination directory given" if !@params.key?(:dest) rescue => e warn("#{parser.program_name}: #{e.message}") warn(parser.help) if e.is_a?(OptionParser::ParseError) exit 1 end
respond_to_missing?(m, *args)
click to toggle source
Calls superclass method
# File lib/photein/config.rb, line 61 def respond_to_missing?(m, *args) @params.key?(m.to_s.tr('_', '-').to_sym) || super end