Class: Typespec::Array

Inherits:
Object
  • Object
show all
Defined in:
lib/typespec.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*elements) ⇒ Array

Returns a new instance of Array.



79
80
81
# File 'lib/typespec.rb', line 79

def initialize(*elements)
  @element = Typespec.or[*elements]
end

Class Method Details

.[](*elements) ⇒ Object



83
84
85
# File 'lib/typespec.rb', line 83

def self.[](*elements)
  Typespec::Array.new(*elements)
end

Instance Method Details

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
# File 'lib/typespec.rb', line 87

def valid?(value)
  if value.is_a? ::Array
    value.all?{|element| @element.valid?(element)}
  else
    false
  end
end