Class: Algebrick::Matchers::Any

Inherits:
Abstract show all
Defined in:
lib/algebrick/matchers/any.rb

Instance Attribute Summary

Attributes inherited from Abstract

#value

Instance Method Summary (collapse)

Methods inherited from Abstract

#!, #&, #===, #>, #assign!, #assign?, #assign_to_s, #assigned?, #assigns, #case, #children_including_self, #collect_assigns, #find_children, #initialize, #inspect, #matchable!, #matched?, #|

Methods included from TypeCheck

#Child!, #Child?, #Match!, #Match?, #Type!, #Type?, error

Constructor Details

This class inherits a constructor from Algebrick::Matchers::Abstract

Instance Method Details

- (Object) ==(other)



26
27
28
# File 'lib/algebrick/matchers/any.rb', line 26

def ==(other)
  other.kind_of? self.class
end

- (Object) children



18
19
20
# File 'lib/algebrick/matchers/any.rb', line 18

def children
  []
end

- (Boolean) matching?(other) (protected)

Returns:



41
42
43
# File 'lib/algebrick/matchers/any.rb', line 41

def matching?(other)
  true
end

- (Object) to_a

transforms *any to many



31
32
33
34
35
36
37
# File 'lib/algebrick/matchers/any.rb', line 31

def to_a
  if assigned?
    super
  else
    [Matchers::Many.new.tap { |m| m.assign! if assign? }]
  end
end

- (Object) to_s



22
23
24
# File 'lib/algebrick/matchers/any.rb', line 22

def to_s
  assign_to_s + 'any'
end