Class: Restspec::Schema::Types::IntegerType

Inherits:
BasicType
  • Object
show all
Defined in:
lib/restspec/schema/types/integer_type.rb

Instance Method Summary collapse

Methods inherited from BasicType

#initialize, #of, #to_s, #totally_valid?, #|

Constructor Details

This class inherits a constructor from Restspec::Schema::Types::BasicType

Instance Method Details

#example_for(attribute) ⇒ Fixnum

Generates a random number.

Parameters:

Returns:

  • (Fixnum)

    A random number.



8
9
10
# File 'lib/restspec/schema/types/integer_type.rb', line 8

def example_for(attribute)
  Faker::Number.digit.to_i
end

#valid?(attribute, value) ⇒ true, false

Validates if the value is an integer (Fixnum).

Parameters:

Returns:

  • (true, false)

    If the value is an integer.



18
19
20
# File 'lib/restspec/schema/types/integer_type.rb', line 18

def valid?(attribute, value)
  value.is_a?(Fixnum)
end