class Algebrick::Matchers::Array
Attributes
matchers[R]
Public Class Methods
call(*matchers)
click to toggle source
# File lib/algebrick/matchers/array.rb, line 18 def self.call(*matchers) new *matchers end
new(*matchers)
click to toggle source
Calls superclass method
Algebrick::Matchers::Abstract.new
# File lib/algebrick/matchers/array.rb, line 24 def initialize(*matchers) super() @matchers = matchers raise ArgumentError, 'many can be only last' if @matchers[0..-2].any? { |v| v.is_a?(Many) } end
Public Instance Methods
==(other)
click to toggle source
# File lib/algebrick/matchers/array.rb, line 38 def ==(other) other.kind_of? self.class and self.matchers == other.matchers end
children()
click to toggle source
# File lib/algebrick/matchers/array.rb, line 30 def children find_children @matchers end
rest?()
click to toggle source
# File lib/algebrick/matchers/array.rb, line 43 def rest? matchers.last.is_a?(Many) end
to_s()
click to toggle source
# File lib/algebrick/matchers/array.rb, line 34 def to_s "#{assign_to_s}#{"Array.(#{matchers.join(',')})" if matchers}" end
Protected Instance Methods
matching?(other)
click to toggle source
# File lib/algebrick/matchers/array.rb, line 49 def matching?(other) return false unless other.kind_of? ::Array if rest? matchers[0..-2].zip(other).all? { |m, v| m === v } and matchers.last === other[(matchers.size-1)..-1] else matchers.size == other.size and matchers.zip(other).all? { |m, v| m === v } end end