Class: WebFunction::Type::ArrayOf
- Inherits:
-
Object
- Object
- WebFunction::Type::ArrayOf
- Defined in:
- lib/web_function/type/array_of.rb
Instance Attribute Summary collapse
-
#base_type ⇒ Object
readonly
Returns the value of attribute base_type.
-
#of ⇒ Object
readonly
Returns the value of attribute of.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #format(format = :default) ⇒ Object
- #hash ⇒ Object
-
#initialize(of) ⇒ ArrayOf
constructor
A new instance of ArrayOf.
- #inspect ⇒ Object
- #objects ⇒ Object
- #refinement ⇒ Object
- #to_s ⇒ Object
- #valid?(value) ⇒ Boolean
- #without_refinements ⇒ Object
Constructor Details
#initialize(of) ⇒ ArrayOf
Returns a new instance of ArrayOf.
8 9 10 11 |
# File 'lib/web_function/type/array_of.rb', line 8 def initialize(of) @base_type = "array" @of = of end |
Instance Attribute Details
#base_type ⇒ Object (readonly)
Returns the value of attribute base_type.
6 7 8 |
# File 'lib/web_function/type/array_of.rb', line 6 def base_type @base_type end |
#of ⇒ Object (readonly)
Returns the value of attribute of.
6 7 8 |
# File 'lib/web_function/type/array_of.rb', line 6 def of @of end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
36 37 38 |
# File 'lib/web_function/type/array_of.rb', line 36 def ==(other) other.is_a?(ArrayOf) && other.of == @of end |
#format(format = :default) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/web_function/type/array_of.rb', line 21 def format(format = :default) case format when :base "array" when :compact, :default "array<#{@of.format(format)}>" else raise ArgumentError, "unknown format: #{format.inspect}" end end |
#hash ⇒ Object
41 42 43 |
# File 'lib/web_function/type/array_of.rb', line 41 def hash [ArrayOf, @of].hash end |
#inspect ⇒ Object
17 18 19 |
# File 'lib/web_function/type/array_of.rb', line 17 def inspect "#<ArrayOf #{@of.inspect}>" end |
#objects ⇒ Object
45 46 47 |
# File 'lib/web_function/type/array_of.rb', line 45 def objects @of.objects end |
#refinement ⇒ Object
13 14 15 |
# File 'lib/web_function/type/array_of.rb', line 13 def refinement nil end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/web_function/type/array_of.rb', line 32 def to_s format(:default) end |
#valid?(value) ⇒ Boolean
53 54 55 |
# File 'lib/web_function/type/array_of.rb', line 53 def valid?(value) value.is_a?(Array) && value.all? { |element| @of.valid?(element) } end |