Class: Cheri::JRuby::Explorer::TypeViewer

Inherits:
Object
  • Object
show all
Defined in:
lib/cheri/jruby/explorer/viewer.rb

Overview

self

Instance Method Summary collapse

Constructor Details

#initialize(type, clazz) ⇒ TypeViewer

Returns a new instance of TypeViewer.



86
87
88
89
90
91
# File 'lib/cheri/jruby/explorer/viewer.rb', line 86

def initialize(type,clazz)
  raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
  raise Cheri.new_type_error(clazz,Class) unless clazz.nil? || Class === clazz
  @t = type
  @c = clazz if clazz
end

Instance Method Details

#[](type) ⇒ Object



110
111
112
113
114
# File 'lib/cheri/jruby/explorer/viewer.rb', line 110

def [](type)
  raise Cheri.new_type_error(type,Symbol,Class,String) unless Symbol === type ||
      Class === type || String === type
  @s ? @s[type] : nil
end

#[]=(type, type_viewer) ⇒ Object



105
106
107
108
109
# File 'lib/cheri/jruby/explorer/viewer.rb', line 105

def []=(type,type_viewer)
  raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
  raise Cheri.new_type_error(type_viewer,TypeViewer) unless TypeViewer === type_viewer
  (@s ||= {})[type] = type_viewer
end

#clazzObject



95
96
97
# File 'lib/cheri/jruby/explorer/viewer.rb', line 95

def clazz
  @c  
end

#clazz=(c) ⇒ Object



98
99
100
101
# File 'lib/cheri/jruby/explorer/viewer.rb', line 98

def clazz=(c)
  raise Cheri.new_type_error(c,Class) unless Class === c
  @c = c
end

#new(*r) ⇒ Object

convenience method for instantiating clazz



117
118
119
# File 'lib/cheri/jruby/explorer/viewer.rb', line 117

def new(*r)
  @c.new(*r) if @c
end

#subtypesObject



102
103
104
# File 'lib/cheri/jruby/explorer/viewer.rb', line 102

def subtypes
  @s  
end

#typeObject



92
93
94
# File 'lib/cheri/jruby/explorer/viewer.rb', line 92

def type
  @t  
end