Class: RubyBreaker::TypeDefs::DuckType
- Defined in:
- lib/rubybreaker/type/type.rb
Overview
This class represents any object with certain methods Usage: [m1,m2,…] where m1…mn are method names
Direct Known Subclasses
Instance Attribute Summary collapse
-
#meth_names ⇒ Object
This accessor sets/gets method names in the duck type.
Attributes inherited from Type
Instance Method Summary collapse
- #add_meth(meth_name) ⇒ Object
-
#initialize(meth_names = [], *args) ⇒ DuckType
constructor
A new instance of DuckType.
Methods inherited from Type
Constructor Details
#initialize(meth_names = [], *args) ⇒ DuckType
Returns a new instance of DuckType.
122 123 124 125 |
# File 'lib/rubybreaker/type/type.rb', line 122 def initialize(meth_names=[],*args) super(*args) @meth_names = meth_names.map!{|n| n.to_sym} end |
Instance Attribute Details
#meth_names ⇒ Object
This accessor sets/gets method names in the duck type.
120 121 122 |
# File 'lib/rubybreaker/type/type.rb', line 120 def meth_names @meth_names end |
Instance Method Details
#add_meth(meth_name) ⇒ Object
126 127 128 |
# File 'lib/rubybreaker/type/type.rb', line 126 def add_meth(meth_name) @meth_names << meth_name.to_sym if !@meth_names.include?(meth_name) end |