class Switch
Public Instance Methods
cmd()
click to toggle source
Returns a command appropriate for executing at the command line.
# File lib/git-utils/switch.rb, line 21 def cmd "git checkout #{other_branch}" end
other_branch()
click to toggle source
Returns the branch to switch to. When multiple branches match, switch to the first one.
# File lib/git-utils/switch.rb, line 16 def other_branch @other_branch ||= `git branch | grep #{pattern}`.split.first end
parser()
click to toggle source
# File lib/git-utils/switch.rb, line 5 def parser OptionParser.new do |opts| opts.banner = "Usage: git switch <pattern>" opts.on_tail("-h", "--help", "this usage guide") do puts opts.to_s; exit 0 end end end
Private Instance Methods
pattern()
click to toggle source
Returns the pattern of the branch to switch to.
# File lib/git-utils/switch.rb, line 28 def pattern self.known_options.first end