Class: MultiGit::RefSpec::Parser
- Inherits:
-
Object
- Object
- MultiGit::RefSpec::Parser
- Defined in:
- lib/multi_git/refspec.rb
Constant Summary collapse
- REF =
%r{\A(\+?)([a-zA-Z/0-9_*]+)?(?:(:)([a-zA-Z/0-9_*]+)?)?\z}
Instance Attribute Summary collapse
-
#from_base ⇒ Object
readonly
Returns the value of attribute from_base.
Instance Method Summary collapse
- #[](*args) ⇒ Object
-
#initialize(from_base = 'refs/heads/', to_base) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(from_base = 'refs/heads/', to_base) ⇒ Parser
Returns a new instance of Parser.
47 48 49 50 |
# File 'lib/multi_git/refspec.rb', line 47 def initialize(from_base = 'refs/heads/', to_base ) @from_base = from_base @to_base = to_base end |
Instance Attribute Details
#from_base ⇒ Object (readonly)
Returns the value of attribute from_base.
45 46 47 |
# File 'lib/multi_git/refspec.rb', line 45 def from_base @from_base end |
Instance Method Details
#[](*args) ⇒ Array<RefSpec> #[](*args, options) ⇒ Array<RefSpec>
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/multi_git/refspec.rb', line 61 def [](*args) forced = false if args.last.kind_of? Hash = args.pop.dup forced = .delete(:forced){ false } args << end args.collect_concat do |arg| if arg.kind_of? RefSpec [arg] elsif arg.kind_of? String [parse_string(arg, forced)] elsif arg.kind_of? Hash arg.map{|k,v| parse_pair(k,v, forced) } elsif arg.kind_of? Range [parse_pair(arg.begin, arg.end, forced)] else raise ArgumentError, "Expected a String, Hash or Range. Got #{arg.inspect}" end end end |