Class: AIGit::Options
- Inherits:
-
Object
- Object
- AIGit::Options
- Defined in:
- lib/ai_git/options.rb
Instance Attribute Summary collapse
-
#assume_yes ⇒ Object
Returns the value of attribute assume_yes.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#force ⇒ Object
Returns the value of attribute force.
-
#help ⇒ Object
Returns the value of attribute help.
-
#push ⇒ Object
Returns the value of attribute push.
Class Method Summary collapse
Instance Method Summary collapse
- #assume_yes? ⇒ Boolean
- #dry_run? ⇒ Boolean
- #force? ⇒ Boolean
- #help? ⇒ Boolean
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #push? ⇒ Boolean
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
16 17 18 19 20 21 22 |
# File 'lib/ai_git/options.rb', line 16 def initialize @dry_run = false @push = true @assume_yes = false @force = false @help = false end |
Instance Attribute Details
#assume_yes ⇒ Object
Returns the value of attribute assume_yes.
14 15 16 |
# File 'lib/ai_git/options.rb', line 14 def assume_yes @assume_yes end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
14 15 16 |
# File 'lib/ai_git/options.rb', line 14 def dry_run @dry_run end |
#force ⇒ Object
Returns the value of attribute force.
14 15 16 |
# File 'lib/ai_git/options.rb', line 14 def force @force end |
#help ⇒ Object
Returns the value of attribute help.
14 15 16 |
# File 'lib/ai_git/options.rb', line 14 def help @help end |
#push ⇒ Object
Returns the value of attribute push.
14 15 16 |
# File 'lib/ai_git/options.rb', line 14 def push @push end |
Class Method Details
.parse(argv) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ai_git/options.rb', line 24 def self.parse(argv) argv.to_a.each_with_object(new) do |arg, | case arg when "-n", "--dry-run" then .dry_run = true when "--no-push" then .push = false when "-y", "--yes" then .assume_yes = true when "-f", "--force" then .force = true when "-h", "--help" then .help = true else raise "Unknown option: #{arg}. Run `ai_git --help` for usage." end end end |
Instance Method Details
#assume_yes? ⇒ Boolean
45 46 47 |
# File 'lib/ai_git/options.rb', line 45 def assume_yes? @assume_yes end |
#dry_run? ⇒ Boolean
37 38 39 |
# File 'lib/ai_git/options.rb', line 37 def dry_run? @dry_run end |
#force? ⇒ Boolean
49 50 51 |
# File 'lib/ai_git/options.rb', line 49 def force? @force end |
#help? ⇒ Boolean
53 54 55 |
# File 'lib/ai_git/options.rb', line 53 def help? @help end |
#push? ⇒ Boolean
41 42 43 |
# File 'lib/ai_git/options.rb', line 41 def push? @push end |