Class: Ree::Contracts::ArgContracts::RespondTo

Inherits:
Object
  • Object
show all
Extended by:
Squarable
Defined in:
lib/ree/contracts/arg_contracts/respond_to.rb

Instance Method Summary collapse

Methods included from Squarable

[]

Constructor Details

#initialize(*method_names) ⇒ RespondTo

Returns a new instance of RespondTo.



8
9
10
# File 'lib/ree/contracts/arg_contracts/respond_to.rb', line 8

def initialize(*method_names)
  @method_names = method_names
end

Instance Method Details

#message(value, name, lvl = 1) ⇒ Object



20
21
22
23
# File 'lib/ree/contracts/arg_contracts/respond_to.rb', line 20

def message(value, name, lvl = 1)
  unrespond_list = get_unrespond_list(value)
  "expected to respond to #{unrespond_list.inspect}}"
end

#to_sObject



16
17
18
# File 'lib/ree/contracts/arg_contracts/respond_to.rb', line 16

def to_s
  "RespondTo#{method_names.inspect}"
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ree/contracts/arg_contracts/respond_to.rb', line 12

def valid?(value)
  get_unrespond_list(value).empty?
end