Class: Apigen::PrimaryType
- Inherits:
-
Object
- Object
- Apigen::PrimaryType
- Defined in:
- lib/apigen/models/primary_type.rb
Overview
PrimaryType represents a primary type such as a string or an integer.
Constant Summary collapse
- PRIMARY_TYPES =
Set.new %i[string int32 bool void]
Instance Attribute Summary collapse
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(shape) ⇒ PrimaryType
constructor
A new instance of PrimaryType.
- #to_s ⇒ Object
- #validate(_model_registry) ⇒ Object
Constructor Details
#initialize(shape) ⇒ PrimaryType
Returns a new instance of PrimaryType.
17 18 19 |
# File 'lib/apigen/models/primary_type.rb', line 17 def initialize(shape) @shape = shape end |
Instance Attribute Details
#shape ⇒ Object (readonly)
Returns the value of attribute shape.
15 16 17 |
# File 'lib/apigen/models/primary_type.rb', line 15 def shape @shape end |
Class Method Details
.primary?(shape) ⇒ Boolean
11 12 13 |
# File 'lib/apigen/models/primary_type.rb', line 11 def self.primary?(shape) PRIMARY_TYPES.include? shape end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 |
# File 'lib/apigen/models/primary_type.rb', line 25 def ==(other) other.is_a?(PrimaryType) && other.shape == shape end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/apigen/models/primary_type.rb', line 29 def to_s @shape.to_s end |
#validate(_model_registry) ⇒ Object
21 22 23 |
# File 'lib/apigen/models/primary_type.rb', line 21 def validate(_model_registry) raise "Unsupported primary type :#{@shape}." unless self.class.primary?(@shape) end |