Class: DuckTesting::Type::DuckType
- Defined in:
- lib/duck_testing/type/duck_type.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ DuckType
constructor
A new instance of DuckType.
- #match?(object) ⇒ Boolean
- #to_s ⇒ String
Constructor Details
#initialize(name) ⇒ DuckType
Returns a new instance of DuckType.
8 9 10 |
# File 'lib/duck_testing/type/duck_type.rb', line 8 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/duck_testing/type/duck_type.rb', line 6 def name @name end |
Instance Method Details
#match?(object) ⇒ Boolean
14 15 16 |
# File 'lib/duck_testing/type/duck_type.rb', line 14 def match?(object) object.respond_to?(name) end |
#to_s ⇒ String
19 20 21 |
# File 'lib/duck_testing/type/duck_type.rb', line 19 def to_s "##{name}" end |