Class: Algebrick::Matchers::Wrapper
- Defined in:
- lib/algebrick/matchers/wrapper.rb
Overview
wraps any object having #=== method into matcher
Instance Attribute Summary collapse
-
#something ⇒ Object
readonly
Returns the value of attribute something.
Attributes inherited from Abstract
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #children ⇒ Object
-
#initialize(something) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #to_s ⇒ Object
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(something) ⇒ Wrapper
Returns a new instance of Wrapper.
25 26 27 28 |
# File 'lib/algebrick/matchers/wrapper.rb', line 25 def initialize(something) super() @something = matchable! something end |
Instance Attribute Details
#something ⇒ Object (readonly)
Returns the value of attribute something.
23 24 25 |
# File 'lib/algebrick/matchers/wrapper.rb', line 23 def something @something end |
Class Method Details
.call(something) ⇒ Object
19 20 21 |
# File 'lib/algebrick/matchers/wrapper.rb', line 19 def self.call(something) new something end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 |
# File 'lib/algebrick/matchers/wrapper.rb', line 38 def ==(other) other.kind_of? self.class and self.something == other.something end |
#children ⇒ Object
30 31 32 |
# File 'lib/algebrick/matchers/wrapper.rb', line 30 def children find_children [@something] end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/algebrick/matchers/wrapper.rb', line 34 def to_s assign_to_s + "Wrapper.(#{@something})" end |