Class: NRSER::Types::IsA

Inherits:
Type
  • Object
show all
Defined in:
lib/nrser/types/is_a.rb

Direct Known Subclasses

ArrayType, HashType

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#check, #from_s, #has_from_s?, #has_to_data?, #name, #respond_to?, short_name, #to_data, #to_s

Constructor Details

#initialize(klass, **options) ⇒ IsA

Returns a new instance of IsA.



9
10
11
12
# File 'lib/nrser/types/is_a.rb', line 9

def initialize klass, **options
  super **options
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



7
8
9
# File 'lib/nrser/types/is_a.rb', line 7

def klass
  @klass
end

Instance Method Details

#default_nameObject



14
15
16
# File 'lib/nrser/types/is_a.rb', line 14

def default_name
  "#{ self.class.short_name }(#{ @klass })"
end

#test(value) ⇒ Object



18
19
20
# File 'lib/nrser/types/is_a.rb', line 18

def test value
  value.is_a? @klass
end