Method: Arrow::HTMLUtilities.make_html_for_object
- Defined in:
- lib/arrow/mixins.rb
.make_html_for_object(object) ⇒ Object
Return an HTML fragment describing the specified object.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/arrow/mixins.rb', line 183 def make_html_for_object( object ) return object.html_inspect if object.respond_to?( :html_inspect ) && ! object.is_a?( HtmlInspectableObject ) object_html = [] case object when Hash object_html << "\n<!-- Hash -->\n" if object.empty? object_html << '{}' else object_html << HASH_HTML_CONTAINER % [ object.collect {|k,v| pairclass = v.instance_variables.empty? ? "simple-hash-pair" : "complex-hash-pair" HASH_PAIR_HTML % [ pairclass, make_html_for_object(k), make_html_for_object(v), ] } ] end when Array object_html << "\n<!-- Array -->\n" if object.empty? object_html << '[]' else object_html << ARRAY_HTML_CONTAINER % [ object.collect {|o| make_html_for_object(o) }.join('</li><li>') ] end else if object.instance_variables.empty? return IMMEDIATE_OBJECT_HTML_CONTAINER % [ HTMLUtilities.escape_html(object.inspect) ] else object_html << make_object_html_wrapper( object ) end end return object_html.join("\n") end |