Class: Rtype::Behavior::And
Instance Method Summary collapse
- #error_message(value) ⇒ Object
-
#initialize(*types) ⇒ And
constructor
A new instance of And.
- #valid?(value) ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(*types) ⇒ And
Returns a new instance of And.
4 5 6 |
# File 'lib/rtype/behavior/and.rb', line 4 def initialize(*types) @types = types end |
Instance Method Details
#error_message(value) ⇒ Object
14 15 16 17 |
# File 'lib/rtype/behavior/and.rb', line 14 def (value) arr = @types.map { |e| Rtype::(e, value) } arr.join "\nAND " end |
#valid?(value) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/rtype/behavior/and.rb', line 8 def valid?(value) @types.all? do |e| Rtype::valid? e, value end end |