Class: VORuby::VOTables::VOTable::Misc::TypeCheck
- Defined in:
- lib/voruby/votables/misc.rb
Overview
A class which checks to see whether the type of the incoming class matches expectation.
Instance Attribute Summary collapse
-
#obj ⇒ Object
Returns the value of attribute obj.
-
#proto ⇒ Object
Returns the value of attribute proto.
Instance Method Summary collapse
-
#check ⇒ Object
Check to see whether the class is of the expected type.
-
#initialize(obj = nil, proto = nil) ⇒ TypeCheck
constructor
- obj:
-
The object in question.
- #to_s ⇒ Object
Constructor Details
#initialize(obj = nil, proto = nil) ⇒ TypeCheck
- obj:
-
The object in question.
- proto:
-
The prototype of the expected class.
30 31 32 33 34 35 36 |
# File 'lib/voruby/votables/misc.rb', line 30 def initialize(obj=nil, proto=nil) #raise "TypeCheck must have an object" if obj == nil #raise "TypeCheck must have a prototype" if proto == nil @obj = obj @proto = proto end |
Instance Attribute Details
#obj ⇒ Object
Returns the value of attribute obj.
24 25 26 |
# File 'lib/voruby/votables/misc.rb', line 24 def obj @obj end |
#proto ⇒ Object
Returns the value of attribute proto.
24 25 26 |
# File 'lib/voruby/votables/misc.rb', line 24 def proto @proto end |
Instance Method Details
#check ⇒ Object
Check to see whether the class is of the expected type.
39 40 41 |
# File 'lib/voruby/votables/misc.rb', line 39 def check raise TypeException.new(@obj, @proto) if @obj and !@obj.is_a?(@proto) end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/voruby/votables/misc.rb', line 43 def to_s "{object=#{@obj};prototype=#{@proto}}" end |