Class: Apigen::EnumType

Inherits:
Object
  • Object
show all
Defined in:
lib/apigen/models/enum_type.rb

Overview

EnumType represents an enum (a type that can be one of several constants).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnumType

Returns a new instance of EnumType.



11
12
13
# File 'lib/apigen/models/enum_type.rb', line 11

def initialize
  @values = []
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



9
10
11
# File 'lib/apigen/models/enum_type.rb', line 9

def values
  @values
end

Instance Method Details

#validate(_model_registry) ⇒ Object



19
20
21
22
23
# File 'lib/apigen/models/enum_type.rb', line 19

def validate(_model_registry)
  @values.each do |val|
    raise 'Enums only support string values' unless val.is_a? String
  end
end

#value(val) ⇒ Object



15
16
17
# File 'lib/apigen/models/enum_type.rb', line 15

def value(val)
  @values << val
end