Class: Algebrick::Matchers::Variant

Inherits:
Wrapper show all
Defined in:
lib/algebrick/matchers/variant.rb

Instance Attribute Summary

Attributes inherited from Wrapper

#something

Attributes inherited from Abstract

#value

Instance Method Summary (collapse)

Methods inherited from Wrapper

#==, call, #children, #matching?

Methods inherited from Abstract

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

Methods included from TypeCheck

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

Constructor Details

- (Variant) initialize(something)

Returns a new instance of Variant

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/algebrick/matchers/variant.rb', line 18

def initialize(something)
  raise ArgumentError unless something.variants
  Type! something, Algebrick::ProductVariant
  super something
end

Instance Method Details

- (Object) to_s



24
25
26
# File 'lib/algebrick/matchers/variant.rb', line 24

def to_s
  assign_to_s + "#{@something.name}.to_m"
end