Class: Svnx::Base::Options
- Inherits:
-
Object
- Object
- Svnx::Base::Options
- Includes:
- ObjectUtil
- Defined in:
- lib/svnx/base/options.rb
Direct Known Subclasses
Svnx::Blame::Options, Cat::Options, Commit::Options, Diff::Options, Info::Options, Log::Options, Merge::Options, Propget::Options, Propset::Options, Status::Options, Update::Options
Class Method Summary collapse
-
.has_fields(*fields) ⇒ Object
Creates a reader method for each field.
Instance Method Summary collapse
- #fields ⇒ Object
- #get_args(field) ⇒ Object
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #options_to_args ⇒ Object
- #to_args ⇒ Object
Methods included from ObjectUtil
#assign, #create_invalid_fields_message, included, #validate
Methods included from ObjectUtil::ClassMethods
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
32 33 34 35 36 |
# File 'lib/svnx/base/options.rb', line 32 def initialize args fkeys = fields.keys assign args, fkeys validate args, fkeys end |
Class Method Details
.has_fields(*fields) ⇒ Object
Creates a reader method for each field
26 27 28 29 |
# File 'lib/svnx/base/options.rb', line 26 def has_fields(*fields) what = Array(fields).flatten attr_reader(*what) end |
Instance Method Details
#fields ⇒ Object
44 45 46 |
# File 'lib/svnx/base/options.rb', line 44 def fields raise "not implemented for #{self.class}" end |
#get_args(field) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/svnx/base/options.rb', line 54 def get_args field val = fields[field] case val when Proc val.call self when nil send field else val end end |
#options_to_args ⇒ Object
38 39 40 41 42 |
# File 'lib/svnx/base/options.rb', line 38 def fields.keys.collect do |fld| [ fld, get_args(fld) ] end end |
#to_args ⇒ Object
48 49 50 51 52 |
# File 'lib/svnx/base/options.rb', line 48 def to_args .collect do |opt| send(opt.first) ? opt[1] : nil end.compact.flatten end |