Class: Ree::Contracts::ArgContracts::Eq

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Squarable

[]

Methods included from Truncatable

#truncate

Constructor Details

#initialize(contract) ⇒ Eq

Returns a new instance of Eq.



11
12
13
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 11

def initialize(contract)
  @contract = contract
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.



9
10
11
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 9

def contract
  @contract
end

Instance Method Details

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



23
24
25
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 23

def message(value, name, lvl = 1)
  "expected #{truncate(self.to_s, 30)}, got #{truncate(value.inspect)}"
end

#to_sObject



19
20
21
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 19

def to_s
  "Eq[#{contract.inspect}]"
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 15

def valid?(value)
  value.equal?(contract)
end