Class: Algebrick::Matchers::Or
- Inherits:
-
AbstractLogic
show all
- Defined in:
- lib/algebrick/matchers/or.rb
Overview
noinspection RubyClassModuleNamingConvention
Instance Attribute Summary
#matchers
Attributes inherited from Abstract
#value
Instance Method Summary
(collapse)
#==, call, #initialize
Methods inherited from Abstract
#!, #&, #==, #===, #>, #assign!, #assign?, #assign_to_s, #assigned?, #assigns, #case, #children_including_self, #find_children, #initialize, #inspect, #matchable!, #matched?, #to_a, #|
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?, error
Instance Method Details
- (Object) assigns_size
45
46
47
48
|
# File 'lib/algebrick/matchers/or.rb', line 45
def assigns_size
super_children.map { |ch| ch.assigns.size }.max
end
|
- (Object) children
32
33
34
|
# File 'lib/algebrick/matchers/or.rb', line 32
def children
super.select &:matched?
end
|
- (Object) collect_assigns
38
39
40
41
42
43
|
# File 'lib/algebrick/matchers/or.rb', line 38
def collect_assigns
super.tap do |assigns|
missing = assigns_size - assigns.size
assigns.push(*::Array.new(missing))
end
end
|
- (Boolean) matching?(other)
25
26
27
|
# File 'lib/algebrick/matchers/or.rb', line 25
def matching?(other)
matchers.any? { |m| m === other }
end
|
- (Object) super_children
29
|
# File 'lib/algebrick/matchers/or.rb', line 29
alias_method :super_children, :children
|
19
20
21
|
# File 'lib/algebrick/matchers/or.rb', line 19
def to_s
matchers.join ' | '
end
|