twitter-status-bot/.gems/doc/json-1.8.1/rdoc/JSON/GenericObject.html

657 lines
23 KiB
HTML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Class: JSON::GenericObject</title>
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
</head>
<body id="top" class="class">
<div id="metadata">
<div id="home-metadata">
<div id="home-section" class="section">
<h3 class="section-header">
<a href="../index.html">Home</a>
<a href="../index.html#classes">Classes</a>
<a href="../index.html#methods">Methods</a>
</h3>
</div>
</div>
<div id="file-metadata">
<div id="file-list-section" class="section">
<h3 class="section-header">In Files</h3>
<div class="section-body">
<ul>
<li><a href="../lib/json/generic_object_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/json/generic_object.rb">lib/json/generic_object.rb</a></li>
</ul>
</div>
</div>
</div>
<div id="class-metadata">
<!-- Parent Class -->
<div id="parent-class-section" class="section">
<h3 class="section-header">Parent</h3>
<p class="link"><a href="../OpenStruct.html">OpenStruct</a></p>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="section">
<h3 class="section-header">Methods</h3>
<ul class="link-list">
<li><a href="#method-c-dump">::dump</a></li>
<li><a href="#method-c-from_hash">::from_hash</a></li>
<li><a href="#method-c-json_creatable-3F">::json_creatable?</a></li>
<li><a href="#method-c-json_create">::json_create</a></li>
<li><a href="#method-c-load">::load</a></li>
<li><a href="#method-i-5B-5D">#[]</a></li>
<li><a href="#method-i-5B-5D-3D">#[]=</a></li>
<li><a href="#method-i-as_json">#as_json</a></li>
<li><a href="#method-i-to_hash">#to_hash</a></li>
<li><a href="#method-i-to_json">#to_json</a></li>
<li><a href="#method-i-7C">#|</a></li>
</ul>
</div>
</div>
<div id="project-metadata">
<div id="fileindex-section" class="section project-section">
<h3 class="section-header">Files</h3>
<ul>
<li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
</ul>
</div>
<div id="classindex-section" class="section project-section">
<h3 class="section-header">Class/Module Index
<span class="search-toggle"><img src="../images/find.png"
height="16" width="16" alt="[+]"
title="show/hide quicksearch" /></span></h3>
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
<fieldset>
<legend>Quicksearch</legend>
<input type="text" name="quicksearch" value=""
class="quicksearch-field" />
</fieldset>
</form>
<ul class="link-list">
<li><a href="../JSON.html">JSON</a></li>
<li><a href="../JSON/Ext.html">JSON::Ext</a></li>
<li><a href="../JSON/GeneratorError.html">JSON::GeneratorError</a></li>
<li><a href="../JSON/GenericObject.html">JSON::GenericObject</a></li>
<li><a href="../JSON/JSONError.html">JSON::JSONError</a></li>
<li><a href="../JSON/MissingUnicodeSupport.html">JSON::MissingUnicodeSupport</a></li>
<li><a href="../JSON/NestingError.html">JSON::NestingError</a></li>
<li><a href="../JSON/ParserError.html">JSON::ParserError</a></li>
<li><a href="../JSON/Pure.html">JSON::Pure</a></li>
<li><a href="../JSON/Pure/Generator.html">JSON::Pure::Generator</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods.html">JSON::Pure::Generator::GeneratorMethods</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/Array.html">JSON::Pure::Generator::GeneratorMethods::Array</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/FalseClass.html">JSON::Pure::Generator::GeneratorMethods::FalseClass</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/Float.html">JSON::Pure::Generator::GeneratorMethods::Float</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/Hash.html">JSON::Pure::Generator::GeneratorMethods::Hash</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/Integer.html">JSON::Pure::Generator::GeneratorMethods::Integer</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/NilClass.html">JSON::Pure::Generator::GeneratorMethods::NilClass</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/Object.html">JSON::Pure::Generator::GeneratorMethods::Object</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/String.html">JSON::Pure::Generator::GeneratorMethods::String</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/String/Extend.html">JSON::Pure::Generator::GeneratorMethods::String::Extend</a></li>
<li><a href="../JSON/Pure/Generator/GeneratorMethods/TrueClass.html">JSON::Pure::Generator::GeneratorMethods::TrueClass</a></li>
<li><a href="../JSON/Pure/Generator/State.html">JSON::Pure::Generator::State</a></li>
<li><a href="../JSON/Pure/Parser.html">JSON::Pure::Parser</a></li>
<li><a href="../JSON/GeneratorError.html">JSON::UnparserError</a></li>
<li><a href="../BigDecimal.html">BigDecimal</a></li>
<li><a href="../Class.html">Class</a></li>
<li><a href="../Complex.html">Complex</a></li>
<li><a href="../Date.html">Date</a></li>
<li><a href="../DateTime.html">DateTime</a></li>
<li><a href="../Exception.html">Exception</a></li>
<li><a href="../Kernel.html">Kernel</a></li>
<li><a href="../OpenStruct.html">OpenStruct</a></li>
<li><a href="../Range.html">Range</a></li>
<li><a href="../Rational.html">Rational</a></li>
<li><a href="../Regexp.html">Regexp</a></li>
<li><a href="../Struct.html">Struct</a></li>
<li><a href="../Symbol.html">Symbol</a></li>
<li><a href="../Time.html">Time</a></li>
</ul>
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
</div>
</div>
</div>
<div id="documentation">
<h1 class="class">JSON::GenericObject</h1>
<div id="description" class="description">
</div><!-- description -->
<div id="5Buntitled-5D" class="documentation-section">
<!-- Attributes -->
<div id="attribute-method-details" class="method-section section">
<h3 class="section-header">Attributes</h3>
<div id="json_creatable-attribute-method" class="method-detail">
<a name="json_creatable"></a>
<a name="json_creatable="></a>
<div class="method-heading attribute-method-heading">
<span class="method-name">json_creatable</span><span
class="attribute-access-type">[W]</span>
</div>
<div class="method-description">
</div>
</div>
</div><!-- attribute-method-details -->
<!-- Methods -->
<div id="public-class-method-details" class="method-section section">
<h3 class="section-header">Public Class Methods</h3>
<div id="dump-method" class="method-detail ">
<a name="method-c-dump"></a>
<div class="method-heading">
<span class="method-name">dump</span><span
class="method-args">(obj, *args)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="dump-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 40</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">dump</span>(<span class="ruby-identifier">obj</span>, *<span class="ruby-identifier">args</span>)
<span class="ruby-operator">::</span><span class="ruby-constant">JSON</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">obj</span>, *<span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- dump-source -->
</div>
</div><!-- dump-method -->
<div id="from_hash-method" class="method-detail ">
<a name="method-c-from_hash"></a>
<div class="method-heading">
<span class="method-name">from_hash</span><span
class="method-args">(object)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="from_hash-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 20</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">from_hash</span>(<span class="ruby-identifier">object</span>)
<span class="ruby-keyword">case</span>
<span class="ruby-keyword">when</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_hash</span>)
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">new</span>
<span class="ruby-identifier">object</span>.<span class="ruby-identifier">to_hash</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">result</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">from_hash</span>(<span class="ruby-identifier">value</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">result</span>
<span class="ruby-keyword">when</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_ary</span>)
<span class="ruby-identifier">object</span>.<span class="ruby-identifier">to_ary</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">from_hash</span>(<span class="ruby-identifier">a</span>) }
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">object</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- from_hash-source -->
</div>
</div><!-- from_hash-method -->
<div id="json_creatable-3F-method" class="method-detail ">
<a name="method-c-json_creatable-3F"></a>
<div class="method-heading">
<span class="method-name">json_creatable?</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="json_creatable-3F-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">json_creatable?</span>
<span class="ruby-ivar">@json_creatable</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- json_creatable-3F-source -->
</div>
</div><!-- json_creatable-3F-method -->
<div id="json_create-method" class="method-detail ">
<a name="method-c-json_create"></a>
<div class="method-heading">
<span class="method-name">json_create</span><span
class="method-args">(data)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="json_create-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 14</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">json_create</span>(<span class="ruby-identifier">data</span>)
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">dup</span>
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">delete</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">create_id</span>
<span class="ruby-keyword">self</span>[<span class="ruby-identifier">data</span>]
<span class="ruby-keyword">end</span></pre>
</div><!-- json_create-source -->
</div>
</div><!-- json_create-method -->
<div id="load-method" class="method-detail ">
<a name="method-c-load"></a>
<div class="method-heading">
<span class="method-name">load</span><span
class="method-args">(source, proc = nil, opts = {})</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="load-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 35</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">proc</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opts</span> = {})
<span class="ruby-identifier">result</span> = <span class="ruby-operator">::</span><span class="ruby-constant">JSON</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">proc</span>, <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value">:object_class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">self</span>))
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">new</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- load-source -->
</div>
</div><!-- load-method -->
</div><!-- public-class-method-details -->
<div id="public-instance-method-details" class="method-section section">
<h3 class="section-header">Public Instance Methods</h3>
<div id="5B-5D-method" class="method-detail ">
<a name="method-i-5B-5D"></a>
<div class="method-heading">
<span class="method-name">[]</span><span
class="method-args">(name)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="5B-5D-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 50</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">name</span>)
<span class="ruby-identifier">table</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>]
<span class="ruby-keyword">end</span></pre>
</div><!-- 5B-5D-source -->
</div>
</div><!-- 5B-5D-method -->
<div id="5B-5D-3D-method" class="method-detail ">
<a name="method-i-5B-5D-3D"></a>
<div class="method-heading">
<span class="method-name">[]=</span><span
class="method-args">(name, value)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="5B-5D-3D-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 54</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
<span class="ruby-identifier">__send__</span> <span class="ruby-node">&quot;#{name}=&quot;</span>, <span class="ruby-identifier">value</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- 5B-5D-3D-source -->
</div>
</div><!-- 5B-5D-3D-method -->
<div id="as_json-method" class="method-detail ">
<a name="method-i-as_json"></a>
<div class="method-heading">
<span class="method-name">as_json</span><span
class="method-args">(*)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="as_json-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 62</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">as_json</span>(*)
{ <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">create_id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span> }.<span class="ruby-identifier">merge</span> <span class="ruby-identifier">to_hash</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- as_json-source -->
</div>
</div><!-- as_json-method -->
<div id="to_hash-method" class="method-detail ">
<a name="method-i-to_hash"></a>
<div class="method-heading">
<span class="method-name">to_hash</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="to_hash-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 46</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_hash</span>
<span class="ruby-identifier">table</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- to_hash-source -->
</div>
</div><!-- to_hash-method -->
<div id="to_json-method" class="method-detail ">
<a name="method-i-to_json"></a>
<div class="method-heading">
<span class="method-name">to_json</span><span
class="method-args">(*a)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="to_json-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_json</span>(*<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">as_json</span>.<span class="ruby-identifier">to_json</span>(*<span class="ruby-identifier">a</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- to_json-source -->
</div>
</div><!-- to_json-method -->
<div id="7C-method" class="method-detail ">
<a name="method-i-7C"></a>
<div class="method-heading">
<span class="method-name">|</span><span
class="method-args">(other)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="7C-source">
<pre>
<span class="ruby-comment"># File lib/json/generic_object.rb, line 58</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">other</span>)
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>[<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_hash</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">to_hash</span>)]
<span class="ruby-keyword">end</span></pre>
</div><!-- 7C-source -->
</div>
</div><!-- 7C-method -->
</div><!-- public-instance-method-details -->
</div><!-- 5Buntitled-5D -->
</div><!-- documentation -->
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
Rdoc Generator</a> 2</small>.</p>
</div>
</body>
</html>