Class: Parameters::Types::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/parameters/types/type.rb

Direct Known Subclasses

Boolean, Object, Proc

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.===(value) ⇒ Boolean

This method is abstract.

Determines if the value is an instance of the Type.

Returns:

  • (Boolean)

    Specifies whether the value is already an instance of the Type.



31
32
33
# File 'lib/parameters/types/type.rb', line 31

def self.===(value)
  false
end

.coerce(value) ⇒ Object

This method is abstract.

Coerces an Object into an instances of the Type.

Parameters:

  • value (Object)

    The value to coerce.

Returns:

  • (Object)

    The coerced value.



46
47
# File 'lib/parameters/types/type.rb', line 46

def self.coerce(value)
end

.to_rubyClass

This method is abstract.

The Ruby Class the type represents.

Returns:

  • (Class)

    A Ruby Class the Type represents.



13
14
# File 'lib/parameters/types/type.rb', line 13

def self.to_ruby
end

Instance Method Details

#<(other) ⇒ ::Boolean

Determines if the instance of the type is related to another Type.

Parameters:

  • other (Type)

    The other type class.

Returns:

  • (::Boolean)

    Specifies whether the instance of the type inherites from another type.

Since:

  • 0.4.0



77
78
79
80
81
82
83
# File 'lib/parameters/types/type.rb', line 77

def <(other)
  if other.kind_of?(Type)
    self.class <= other.class
  else
    self.class <= other
  end
end

#<=(other) ⇒ ::Boolean

Compares the type to another instance or class type.

Parameters:

  • other (Type)

    The other instance or class type.

Returns:

  • (::Boolean)

    Specifies whether the instance type inherits from the other class type, or shares the same class as the other instance type.

Since:

  • 0.4.0



97
98
99
# File 'lib/parameters/types/type.rb', line 97

def <=(other)
  (self < other) || (self == other)
end

#==(other) ⇒ ::Boolean

Compares the instance type to another instance type.

Parameters:

  • other (Type)

    The other instance type.

Returns:

  • (::Boolean)

    Specifies that the type has the same class as the other instance type.

Since:

  • 0.4.0



61
62
63
# File 'lib/parameters/types/type.rb', line 61

def ==(other)
  self.class == other.class
end

#===(value) ⇒ Object

See Also:



104
105
106
# File 'lib/parameters/types/type.rb', line 104

def ===(value)
  self.class === value
end

#coerce(value) ⇒ Object

See Also:



111
112
113
# File 'lib/parameters/types/type.rb', line 111

def coerce(value)
  self.class.coerce(value)
end

#to_rubyObject

See Also:



19
20
21
# File 'lib/parameters/types/type.rb', line 19

def to_ruby
  self.class.to_ruby
end