Class: Apigen::ArrayType
- Inherits:
-
Object
- Object
- Apigen::ArrayType
- Defined in:
- lib/apigen/model.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.
178 179 180 |
# File 'lib/apigen/model.rb', line 178 def initialize(type = nil) @type = type end |
Instance Method Details
#repr(indent) ⇒ Object
196 197 198 199 200 201 202 203 |
# File 'lib/apigen/model.rb', line 196 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
192 193 194 |
# File 'lib/apigen/model.rb', line 192 def to_s repr '' end |
#type(item_type = nil, &block) ⇒ Object
182 183 184 185 |
# File 'lib/apigen/model.rb', line 182 def type(item_type = nil, &block) return @type unless item_type @type = Apigen::Model.type item_type, &block end |
#validate(model_registry) ⇒ Object
187 188 189 190 |
# File 'lib/apigen/model.rb', line 187 def validate(model_registry) raise 'Use `type [typename]` to specify the type of types in an array.' unless @type model_registry.check_type @type end |