Class: Algebrick::Matchers::Array
Instance Attribute Summary collapse
Attributes inherited from Abstract
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Abstract
#!, #&, #===, #>, #assign!, #assign?, #assign_to_s, #assigned?, #assigns, #case, #children_including_self, #inspect, #matched?, #to_a, #|
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Constructor Details
#initialize(*matchers) ⇒ Array
Returns a new instance of Array.
24
25
26
27
28
|
# 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
|
Instance Attribute Details
Returns the value of attribute matchers.
22
23
24
|
# File 'lib/algebrick/matchers/array.rb', line 22
def matchers
@matchers
end
|
Class Method Details
.call(*matchers) ⇒ Object
18
19
20
|
# File 'lib/algebrick/matchers/array.rb', line 18
def self.call(*matchers)
new *matchers
end
|
Instance Method Details
#==(other) ⇒ Object
38
39
40
41
|
# File 'lib/algebrick/matchers/array.rb', line 38
def ==(other)
other.kind_of? self.class and
self.matchers == other.matchers
end
|
30
31
32
|
# File 'lib/algebrick/matchers/array.rb', line 30
def children
find_children @matchers
end
|
43
44
45
|
# File 'lib/algebrick/matchers/array.rb', line 43
def rest?
matchers.last.is_a?(Many)
end
|
34
35
36
|
# File 'lib/algebrick/matchers/array.rb', line 34
def to_s
"#{assign_to_s}#{"Array.(#{matchers.join(',')})" if matchers}"
end
|