Class: Fried::Typings::Is

Inherits:
Object
  • Object
show all
Includes:
MetaType, Type
Defined in:
lib/fried/typings/is.rb

Overview

Checks if the object #is_a? object of the passed type

Instance Method Summary collapse

Methods included from Type

#<=>, #call, included

Methods included from MetaType

included

Constructor Details

#initialize(type) ⇒ Is

Returns a new instance of Is.



17
18
19
# File 'lib/fried/typings/is.rb', line 17

def initialize(type)
  @type = type
end

Instance Method Details

#valid?(obj) ⇒ Boolean

Returns:



21
22
23
24
25
# File 'lib/fried/typings/is.rb', line 21

def valid?(obj)
  return type.valid?(obj) if type < Type

  obj.is_a?(type)
end