Class: Apigen::ArrayType
- Inherits:
-
Object
- Object
- Apigen::ArrayType
- Defined in:
- lib/apigen/models/array_type.rb
Overview
ArrayType represents an array type, with a given item type.
Instance Method Summary collapse
-
#initialize(type = nil) ⇒ ArrayType
constructor
A new instance of ArrayType.
- #repr(indent) ⇒ Object
- #to_s ⇒ Object
- #type(item_type = nil, &block) ⇒ Object
- #validate(model_registry) ⇒ Object
Constructor Details
#initialize(type = nil) ⇒ ArrayType
Returns a new instance of ArrayType.
7 8 9 |
# File 'lib/apigen/models/array_type.rb', line 7 def initialize(type = nil) @type = type end |
Instance Method Details
#repr(indent) ⇒ Object
25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
21 22 23 |
# File 'lib/apigen/models/array_type.rb', line 21 def to_s repr '' end |
#type(item_type = nil, &block) ⇒ Object
11 12 13 14 |
# 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) ⇒ Object
16 17 18 19 |
# 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 |