class GitFeats::Args

Public Class Methods

new(*args) click to toggle source

Makes a new Args object

Calls superclass method
# File lib/git-feats/args.rb, line 5
def initialize(*args)
  super
  @executable = ENV["GIT"] || "git"
end

Public Instance Methods

match?(pattern) click to toggle source

Checks if a pattern (string of args) matches the first arguments in an Args object

Examples:

Args(‘init’).match?(‘init’) #=> true Args(‘add’, ‘.’).match?(‘add .’) #=> true Args(‘commit’, ‘-a’, ‘-m’).match?(‘commit -a’) #=> true

Args(‘commit’).match?(‘init’) #=> false Args(‘commit’).match?(‘commit -a’) #=> false

Returns a boolean

# File lib/git-feats/args.rb, line 33
def match?(pattern)
  pattern.split.each_with_index do |arg, index|
    return false unless arg == self[index]
  end
  return true
end
to_exec(args = self) click to toggle source

Returns an executable command that can be called with exec

args - The args of the command

Returns an array of args prepended with an executable

# File lib/git-feats/args.rb, line 16
def to_exec(args = self)
  Array(@executable) + args
end