Class: Apiwork::Introspection::Param::Time

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

Overview

Time param representing time-of-day values.

Examples:

Basic usage

param.type # => :time
param.scalar? # => true
param.time? # => true

Capabilities

param.formattable? # => false

Enum

if param.enum?
  param.enum # => ["09:00", "17:00"]
  param.enum_reference? # => false
end

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#concrete?Boolean

Whether this param is concrete.

Returns:



46
47
48
# File 'lib/apiwork/introspection/param/time.rb', line 46

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:



30
31
32
# File 'lib/apiwork/introspection/param/time.rb', line 30

def default
  @dump[:default]
end

#enumArray<String>, ...

The enum for this param.

Returns:



70
71
72
# File 'lib/apiwork/introspection/param/time.rb', line 70

def enum
  @dump[:enum]
end

#enum?Boolean

Whether this param has an enum.

Returns:



62
63
64
# File 'lib/apiwork/introspection/param/time.rb', line 62

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

#enum_reference?Boolean

Whether this param is an enum reference.

Returns:



78
79
80
# File 'lib/apiwork/introspection/param/time.rb', line 78

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

#exampleObject?

The example for this param.

Returns:



38
39
40
# File 'lib/apiwork/introspection/param/time.rb', line 38

def example
  @dump[:example]
end

#formattable?Boolean

Whether this param is formattable.

Returns:



94
95
96
# File 'lib/apiwork/introspection/param/time.rb', line 94

def formattable?
  false
end

#scalar?Boolean

Whether this param is scalar.

Returns:



54
55
56
# File 'lib/apiwork/introspection/param/time.rb', line 54

def scalar?
  true
end

#time?Boolean

Whether this param is a time.

Returns:



86
87
88
# File 'lib/apiwork/introspection/param/time.rb', line 86

def time?
  true
end

#to_hHash

Converts this param to a hash.

Returns:

  • (Hash)


102
103
104
105
106
107
108
# File 'lib/apiwork/introspection/param/time.rb', line 102

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