Class: GitSwitch::Options
- Inherits:
-
Object
- Object
- GitSwitch::Options
- Defined in:
- lib/git_switch/options.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
- #global? ⇒ Boolean
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #list? ⇒ Boolean
- #valid_args? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
4 5 6 |
# File 'lib/git_switch/options.rb', line 4 def initialize(args) @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/git_switch/options.rb', line 3 def args @args end |
Instance Method Details
#global? ⇒ Boolean
24 25 26 |
# File 'lib/git_switch/options.rb', line 24 def global? (args.include? '-g') || (args.include? '--global') end |
#list? ⇒ Boolean
20 21 22 |
# File 'lib/git_switch/options.rb', line 20 def list? (args.include? '-l') || (args.include? '--list') end |
#valid_args? ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/git_switch/options.rb', line 8 def valid_args? if list? && args.count > 1 puts "Invalid args" return false elsif no_flags?(args) || one_flag?(args) return true else puts "Invalid args" return false end end |