Class: OpenAPIGenerateTypeScriptFetch::ObjectSchemaProperty

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/openapi_generate_typescript_fetch/schema.rb

Overview

Contains info about a property of an object schema.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, spec:, name: nil, req: false, pattern: false, additional: false) ⇒ ObjectSchemaProperty

Returns a new instance of ObjectSchemaProperty.



16
17
18
19
20
21
22
23
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 16

def initialize(type:, spec:, name: nil, req: false, pattern: false, additional: false)
  @name = name
  @req = req
  @type = type
  @pattern = pattern
  @additional = additional
  @spec = spec
end

Instance Attribute Details

#additionalObject (readonly)

Returns the value of attribute additional.



14
15
16
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 14

def additional
  @additional
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 14

def name
  @name
end

#patternObject (readonly)

Returns the value of attribute pattern.



14
15
16
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 14

def pattern
  @pattern
end

#reqObject (readonly)

Returns the value of attribute req.



14
15
16
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 14

def req
  @req
end

#specObject (readonly)

Returns the value of attribute spec.



14
15
16
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 14

def spec
  @spec
end

#typeObject (readonly)

Returns the value of attribute type.



14
15
16
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 14

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 25

def <=>(other)
  return -1 if !@name.nil? && other.name.nil?
  return 1 if @name.nil? && !other.name.nil?
  d = @name <=> other.name
  return d unless d.zero?
  d = @pattern <=> other.pattern
  return d unless d.zero?
  d = @additional <=> other.additional
  return d unless d.zero?
  d = @type <=> other.type
  return d unless d.zero?
  @spec <=> other.spec
end

#to_sObject



39
40
41
# File 'lib/openapi_generate_typescript_fetch/schema.rb', line 39

def to_s
  "ObjectSchemaProperty(name: #{@name}, req: #{@req}, type: #{@type}, pattern: #{@pattern}, additional: #{@additional}, spec: #{@spec})"
end