class Apigen::ArrayType

ArrayType represents an array type, with a given item type.

Public Class Methods

new(type = nil) click to toggle source
# File lib/apigen/models/array_type.rb, line 7
def initialize(type = nil)
  @type = type
end

Public Instance Methods

repr(indent) click to toggle source
# File lib/apigen/models/array_type.rb, line 25
def repr(indent)
  type_repr = if @type.respond_to? :repr
                @type.repr indent
              else
                @type.to_s
              end
  "ArrayType<#{type_repr}>"
end
to_s() click to toggle source
# File lib/apigen/models/array_type.rb, line 21
def to_s
  repr ''
end
type(item_type = nil, &block) click to toggle source
# File lib/apigen/models/array_type.rb, line 11
def type(item_type = nil, &block)
  return @type unless item_type
  @type = Apigen::Model.type item_type, &block
end
validate(model_registry) click to toggle source
# File lib/apigen/models/array_type.rb, line 16
def validate(model_registry)
  raise 'Use `type [typename]` to specify the type of items in an array.' unless @type
  model_registry.check_type @type
end