Class: Mal::OnlyT
- Inherits:
-
Object
show all
- Defined in:
- lib/mal.rb
Instance Method Summary
collapse
Constructor Details
#initialize(matchable) ⇒ OnlyT
Returns a new instance of OnlyT.
66
67
68
|
# File 'lib/mal.rb', line 66
def initialize(matchable)
@matchable = matchable
end
|
Instance Method Details
#&(another) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/mal.rb', line 86
def &(another)
if another.is_a?(AnythingT)
self
else
UnionT.new(self, another)
end
end
|
#===(value) ⇒ Object
70
71
72
|
# File 'lib/mal.rb', line 70
def ===(value)
@matchable === value
end
|
#inspect ⇒ Object
74
75
76
|
# File 'lib/mal.rb', line 74
def inspect
'Only(%s)' % @matchable.inspect
end
|
#|(another) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/mal.rb', line 78
def |(another)
if another.is_a?(AnythingT)
another
else
EitherT.new(self, another)
end
end
|