Class: Gitw::GitAllowedOpt
- Inherits:
-
Object
- Object
- Gitw::GitAllowedOpt
- Defined in:
- lib/gitw/git_opts.rb
Overview
git allowed options to defined single allowed options to be included in git options
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#long ⇒ Object
readonly
Returns the value of attribute long.
-
#multiple ⇒ Object
readonly
Returns the value of attribute multiple.
-
#short ⇒ Object
readonly
Returns the value of attribute short.
-
#with_arg ⇒ Object
readonly
Returns the value of attribute with_arg.
Instance Method Summary collapse
- #build_opt(arg = nil) ⇒ Object
- #each_label(&block) ⇒ Object
-
#initialize(label, short: nil, long: nil, with_arg: false, multiple: false) ⇒ GitAllowedOpt
constructor
A new instance of GitAllowedOpt.
Constructor Details
#initialize(label, short: nil, long: nil, with_arg: false, multiple: false) ⇒ GitAllowedOpt
Returns a new instance of GitAllowedOpt.
80 81 82 83 84 85 86 |
# File 'lib/gitw/git_opts.rb', line 80 def initialize(label, short: nil, long: nil, with_arg: false, multiple: false) @label = label.to_s.to_sym @short = short @long = long @with_arg = with_arg @multiple = multiple end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
78 79 80 |
# File 'lib/gitw/git_opts.rb', line 78 def label @label end |
#long ⇒ Object (readonly)
Returns the value of attribute long.
78 79 80 |
# File 'lib/gitw/git_opts.rb', line 78 def long @long end |
#multiple ⇒ Object (readonly)
Returns the value of attribute multiple.
78 79 80 |
# File 'lib/gitw/git_opts.rb', line 78 def multiple @multiple end |
#short ⇒ Object (readonly)
Returns the value of attribute short.
78 79 80 |
# File 'lib/gitw/git_opts.rb', line 78 def short @short end |
#with_arg ⇒ Object (readonly)
Returns the value of attribute with_arg.
78 79 80 |
# File 'lib/gitw/git_opts.rb', line 78 def with_arg @with_arg end |
Instance Method Details
#build_opt(arg = nil) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/gitw/git_opts.rb', line 92 def build_opt(arg = nil) return if with_arg && arg.nil? opt = [] opt << (long || short) opt << arg if with_arg opt.compact end |
#each_label(&block) ⇒ Object
88 89 90 |
# File 'lib/gitw/git_opts.rb', line 88 def each_label(&block) [label, label.to_s, short, long].compact.each(&block) end |