Class: WRI::Server::NS
- Inherits:
-
Object
- Object
- WRI::Server::NS
- Defined in:
- lib/wri/server.rb
Instance Attribute Summary collapse
-
#class_methods ⇒ Object
readonly
Returns the value of attribute class_methods.
-
#instance_methods ⇒ Object
readonly
Returns the value of attribute instance_methods.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#subspaces ⇒ Object
readonly
Returns the value of attribute subspaces.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #esc(text) ⇒ Object
- #full_name ⇒ Object
-
#initialize(name, parent = nil) ⇒ NS
constructor
A new instance of NS.
- #inspect ⇒ Object
- #key ⇒ Object
- #root? ⇒ Boolean
- #to_html ⇒ Object
Constructor Details
Instance Attribute Details
#class_methods ⇒ Object (readonly)
Returns the value of attribute class_methods.
93 94 95 |
# File 'lib/wri/server.rb', line 93 def class_methods @class_methods end |
#instance_methods ⇒ Object (readonly)
Returns the value of attribute instance_methods.
92 93 94 |
# File 'lib/wri/server.rb', line 92 def instance_methods @instance_methods end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
89 90 91 |
# File 'lib/wri/server.rb', line 89 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
90 91 92 |
# File 'lib/wri/server.rb', line 90 def parent @parent end |
#subspaces ⇒ Object (readonly)
Returns the value of attribute subspaces.
91 92 93 |
# File 'lib/wri/server.rb', line 91 def subspaces @subspaces end |
Instance Method Details
#[](name) ⇒ Object
107 108 109 |
# File 'lib/wri/server.rb', line 107 def [](name) @subspaces[name] end |
#[]=(name, value) ⇒ Object
111 112 113 |
# File 'lib/wri/server.rb', line 111 def []=(name, value) @subspaces[name] = value end |
#esc(text) ⇒ Object
173 174 175 |
# File 'lib/wri/server.rb', line 173 def esc(text) CGI.escape(text.to_s) end |
#full_name ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/wri/server.rb', line 119 def full_name if root? nil else [parent.full_name, name].compact.join("::") end end |
#inspect ⇒ Object
177 178 179 |
# File 'lib/wri/server.rb', line 177 def inspect "<#{self.class} #{name}>" end |
#key ⇒ Object
103 104 105 |
# File 'lib/wri/server.rb', line 103 def key full_name end |
#root? ⇒ Boolean
115 116 117 |
# File 'lib/wri/server.rb', line 115 def root? !parent end |
#to_html ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/wri/server.rb', line 127 def to_html markup = [] if root? markup << %[<div class="root">] else markup << %[ <li class="trigger"> <img src="img/dir.gif" onClick="showBranch(this);"/> <span class="link" onClick="lookup(this, '#{full_name}');">#{name}</span> ] markup << %[<div class="branch">] end markup << %[<ul>] class_methods.each do |method| markup << %[ <li class="leaf"> <span class="link" onClick="lookup(this, '#{full_name}::#{method}');">#{method}</span> </li> ] end instance_methods.each do |method| markup << %[ <li class="leaf"> <span class="link" onClick="lookup(this, '#{full_name}-#{method}');">#{method}</span> </li> ] end subspaces.to_a.sort{ |a,b| a[0].to_s <=> b[0].to_s }.each do |(name, subspace)| #subspaces.each do |name, subspace| markup << subspace.to_html end markup << %[</ul>] if root? markup << %[</div>] else markup << %[</div>] markup << %[</li>] end return markup.join("\n") end |