Class: DRbQS::Setting::Base
- Inherits:
-
Object
- Object
- DRbQS::Setting::Base
- Extended by:
- Forwardable
- Includes:
- Misc
- Defined in:
- lib/drbqs/setting/base.rb
Overview
A base class having options of commands. We must define a method 'exec' this method in a child class.
Constant Summary
Constants included from Misc
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(opts = {}, &block) ⇒ Base
constructor
The keys of options are.
-
#parse! ⇒ Object
We execute DRbQS::Setting::Base#parse! before execute 'exec'.
- #string_for_shell ⇒ Object
- #value ⇒ Object
Methods included from Misc
create_logger, create_uri, output_error, process_running_normally?, random_key, time_to_history_string, time_to_history_string2, uri_drbunix
Constructor Details
#initialize(opts = {}, &block) ⇒ Base
The keys of options are
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/drbqs/setting/base.rb', line 22 def initialize(opts = {}, &block) @source = DRbQS::Setting::Source.new(opts[:all_keys_defined]) @source.register_key(:debug, :bool => true) if opts[:log_level] @source.register_key(:log_level, :check => 1, :default => [Logger::ERROR]) end if opts[:daemon] @__daemon__ = nil @source.register_key(:daemon, :check => 1) end @source.instance_eval(&block) if block_given? @options = {} end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
16 17 18 |
# File 'lib/drbqs/setting/base.rb', line 16 def source @source end |
Instance Method Details
#clone ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/drbqs/setting/base.rb', line 54 def clone new_obj = self.class.new instance_variables.each do |var_name| var = instance_variable_get(var_name) case var when NilClass, FalseClass, TrueClass, Symbol new_var = var else new_var = var.clone end new_obj.instance_variable_set(var_name, new_var) end new_obj end |
#parse! ⇒ Object
We execute DRbQS::Setting::Base#parse! before execute 'exec'.
74 75 76 77 78 79 80 |
# File 'lib/drbqs/setting/base.rb', line 74 def parse! preprocess! @source.check! $DEBUG = true if get_first(:debug) @__daemon__ = get_first(:daemon) parse_log_level end |
#string_for_shell ⇒ Object
46 47 48 |
# File 'lib/drbqs/setting/base.rb', line 46 def string_for_shell command_line_argument(true).join(" ") end |
#value ⇒ Object
50 51 52 |
# File 'lib/drbqs/setting/base.rb', line 50 def value @source.value end |