Class: Thy::Types::Array
- Inherits:
-
Object
- Object
- Thy::Types::Array
- Defined in:
- lib/thy/types/array.rb
Instance Method Summary collapse
- #check(values) ⇒ Object
-
#initialize(type) ⇒ Array
constructor
A new instance of Array.
Constructor Details
#initialize(type) ⇒ Array
Returns a new instance of Array.
6 7 8 |
# File 'lib/thy/types/array.rb', line 6 def initialize(type) @type = type end |
Instance Method Details
#check(values) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/thy/types/array.rb', line 10 def check(values) unless values.is_a?(::Array) return Result::Failure.new("Expected an array, but got #{values.inspect}") end values.each do |value| if @type.check(value).failure? return Result::Failure.new( "Expected an array of #{@type.inspect}, but got element: #{value.inspect}", ) end end Result::Success end |