Class: Apiwork::Introspection::Param::Integer

Inherits:
Base
  • Object
show all
Defined in:
lib/apiwork/introspection/param/integer.rb

Overview

Integer param representing whole number values.

Examples:

Basic usage

param.type # => :integer
param.scalar? # => true
param.integer? # => true
param.numeric? # => true

Constraints

param.min # => 0 or nil
param.max # => 100 or nil
param.format # => :int32 or nil
param.boundable? # => true
param.formattable? # => true

Enum

if param.enum?
  param.enum # => [1, 2, 3]
  param.enum_reference? # => false
end

Instance Method Summary collapse

Methods inherited from Base

#array?, #binary?, #boolean?, #date?, #datetime?, #decimal?, #default?, #deprecated?, #description, #initialize, #literal?, #nullable?, #number?, #object?, #optional?, #partial?, #record?, #reference?, #string?, #tag, #time?, #type, #union?, #unknown?, #uuid?

Constructor Details

This class inherits a constructor from Apiwork::Introspection::Param::Base

Instance Method Details

#boundable?Boolean

Whether this param is boundable.

Returns:



123
124
125
# File 'lib/apiwork/introspection/param/integer.rb', line 123

def boundable?
  true
end

#concrete?Boolean

Whether this param is concrete.

Returns:



75
76
77
# File 'lib/apiwork/introspection/param/integer.rb', line 75

def concrete?
  true
end

#defaultObject?

The default for this param.

Returns ‘nil` for both “no default” and “default is explicitly `nil`”. Use Base#default? to distinguish these cases.

Returns:



35
36
37
# File 'lib/apiwork/introspection/param/integer.rb', line 35

def default
  @dump[:default]
end

#enumArray<Integer>, ...

The enum for this param.

Returns:



99
100
101
# File 'lib/apiwork/introspection/param/integer.rb', line 99

def enum
  @dump[:enum]
end

#enum?Boolean

Whether this param has an enum.

Returns:



91
92
93
# File 'lib/apiwork/introspection/param/integer.rb', line 91

def enum?
  @dump[:enum].present?
end

#enum_reference?Boolean

Whether this param is an enum reference.

Returns:



107
108
109
# File 'lib/apiwork/introspection/param/integer.rb', line 107

def enum_reference?
  @dump[:enum].is_a?(Symbol)
end

#exampleObject?

The example for this param.

Returns:



43
44
45
# File 'lib/apiwork/introspection/param/integer.rb', line 43

def example
  @dump[:example]
end

#formatSymbol?

The format for this param.

Returns:

  • (Symbol, nil)


67
68
69
# File 'lib/apiwork/introspection/param/integer.rb', line 67

def format
  @dump[:format]
end

#formattable?Boolean

Whether this param is formattable.

Returns:



131
132
133
# File 'lib/apiwork/introspection/param/integer.rb', line 131

def formattable?
  true
end

#integer?Boolean

Whether this param is an integer.

Returns:



139
140
141
# File 'lib/apiwork/introspection/param/integer.rb', line 139

def integer?
  true
end

#maxNumeric?

The maximum for this param.

Returns:

  • (Numeric, nil)


59
60
61
# File 'lib/apiwork/introspection/param/integer.rb', line 59

def max
  @dump[:max]
end

#minNumeric?

The minimum for this param.

Returns:

  • (Numeric, nil)


51
52
53
# File 'lib/apiwork/introspection/param/integer.rb', line 51

def min
  @dump[:min]
end

#numeric?Boolean

Whether this param is numeric.

Returns:



115
116
117
# File 'lib/apiwork/introspection/param/integer.rb', line 115

def numeric?
  true
end

#scalar?Boolean

Whether this param is scalar.

Returns:



83
84
85
# File 'lib/apiwork/introspection/param/integer.rb', line 83

def scalar?
  true
end

#to_hHash

Converts this param to a hash.

Returns:

  • (Hash)


147
148
149
150
151
152
153
154
155
156
# File 'lib/apiwork/introspection/param/integer.rb', line 147

def to_h
  result = super
  result[:default] = default
  result[:enum] = enum if enum?
  result[:example] = example
  result[:format] = format
  result[:max] = max
  result[:min] = min
  result
end