Class: WebInvoice::CLI::Params
- Inherits:
-
Object
- Object
- WebInvoice::CLI::Params
- Defined in:
- lib/web_invoice/cli.rb
Instance Attribute Summary collapse
-
#service_config ⇒ Object
readonly
Returns the value of attribute service_config.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
-
#initialize(args) ⇒ Params
constructor
A new instance of Params.
- #service_class ⇒ Object
Constructor Details
#initialize(args) ⇒ Params
Returns a new instance of Params.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/web_invoice/cli.rb', line 9 def initialize(args) opt = OptionParser.new opt.on('-c config-file', 'default: ~/.webinvoicerc') { |v| @config = YAML.load_file(v) } opt.on('-d download-dir','default: .' ) { |v| @download_to = v } opt.on('-s service', 'default: saison_card') { |v| @service_name = v } opt.on('-u user') { |v| @user = v } opt.on('-p password') { |v| @password = v } opt.parse! args @config ||= YAML.load_file(File.join(ENV['HOME'], '.webinvoicerc')) @service_name = lookup_master_service @service_config = symbolize_keys(@config['services'][@service_name]) @service_config[:download_to] = @download_to if @download_to @service_config[:user] = @user if @user @service_config[:password] = @password if @password end |
Instance Attribute Details
#service_config ⇒ Object (readonly)
Returns the value of attribute service_config.
24 25 26 |
# File 'lib/web_invoice/cli.rb', line 24 def service_config @service_config end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
24 25 26 |
# File 'lib/web_invoice/cli.rb', line 24 def service_name @service_name end |
Instance Method Details
#service_class ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/web_invoice/cli.rb', line 25 def service_class begin eval "WebInvoice::#{service_name.split(/_/).map { |w| w.capitalize }.join('')}" rescue nil end end |