Class: Mal::ObjectT
Instance Attribute Summary collapse
-
#supported_methods ⇒ Object
readonly
Returns the value of attribute supported_methods.
Instance Method Summary collapse
- #&(another) ⇒ Object
- #===(value) ⇒ Object
-
#initialize(*supported_methods) ⇒ ObjectT
constructor
A new instance of ObjectT.
- #inspect ⇒ Object
Methods inherited from OnlyT
Constructor Details
#initialize(*supported_methods) ⇒ ObjectT
Returns a new instance of ObjectT.
121 122 123 |
# File 'lib/mal.rb', line 121 def initialize(*supported_methods) @supported_methods = supported_methods.map(&:to_sym) end |
Instance Attribute Details
#supported_methods ⇒ Object (readonly)
Returns the value of attribute supported_methods.
120 121 122 |
# File 'lib/mal.rb', line 120 def supported_methods @supported_methods end |
Instance Method Details
#&(another) ⇒ Object
136 137 138 139 140 141 |
# File 'lib/mal.rb', line 136 def &(another) if another.is_a?(ObjectT) methods_of_both = (@supported_methods + another.supported_methods).uniq ObjectT.new(*methods_of_both) end end |
#===(value) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/mal.rb', line 125 def ===(value) @supported_methods.each do |m| return false unless value.respond_to?(m) end true end |
#inspect ⇒ Object
132 133 134 |
# File 'lib/mal.rb', line 132 def inspect 'ObjectWith(%s)' % @supported_methods.map(&:inspect).join(', ') end |