Class: Contraction::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/type_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Type

Returns a new instance of Type.



42
43
44
# File 'lib/parser/type_parser.rb', line 42

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



41
42
43
# File 'lib/parser/type_parser.rb', line 41

def klass
  @klass
end

Instance Method Details

#check(thing) ⇒ Object



50
51
52
# File 'lib/parser/type_parser.rb', line 50

def check(thing)
  works_as_a?(thing)
end

#works_as_a?(thing) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/parser/type_parser.rb', line 46

def works_as_a?(thing)
  thing == klass || thing.is_a?(klass)
end