Class: AIGit::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_git/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

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_yesObject

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_runObject

Returns the value of attribute dry_run.



14
15
16
# File 'lib/ai_git/options.rb', line 14

def dry_run
  @dry_run
end

#forceObject

Returns the value of attribute force.



14
15
16
# File 'lib/ai_git/options.rb', line 14

def force
  @force
end

#helpObject

Returns the value of attribute help.



14
15
16
# File 'lib/ai_git/options.rb', line 14

def help
  @help
end

#pushObject

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, options|
    case arg
    when "-n", "--dry-run" then options.dry_run = true
    when "--no-push"       then options.push = false
    when "-y", "--yes"     then options.assume_yes = true
    when "-f", "--force"   then options.force = true
    when "-h", "--help"    then options.help = true
    else raise "Unknown option: #{arg}. Run `ai_git --help` for usage."
    end
  end
end

Instance Method Details

#assume_yes?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ai_git/options.rb', line 45

def assume_yes?
  @assume_yes
end

#dry_run?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/ai_git/options.rb', line 37

def dry_run?
  @dry_run
end

#force?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ai_git/options.rb', line 49

def force?
  @force
end

#help?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ai_git/options.rb', line 53

def help?
  @help
end

#push?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ai_git/options.rb', line 41

def push?
  @push
end