Class: DuckTesting::Type::DuckType

Inherits:
Base
  • Object
show all
Defined in:
lib/duck_testing/type/duck_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

Parameters:

Returns:



14
15
16
# File 'lib/duck_testing/type/duck_type.rb', line 14

def match?(object)
  object.respond_to?(name)
end

#to_sString

Returns:



19
20
21
# File 'lib/duck_testing/type/duck_type.rb', line 19

def to_s
  "##{name}"
end