Class: Rdio::JSONObj
Overview
An Object that is based on json with simple types
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Instance Method Summary collapse
-
#initialize(json) ⇒ JSONObj
constructor
A new instance of JSONObj.
- #method_missing(method, args = {}) ⇒ Object
Constructor Details
#initialize(json) ⇒ JSONObj
Returns a new instance of JSONObj.
166 167 168 |
# File 'lib/rdio/base.rb', line 166 def initialize(json) @json = json end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, args = {}) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/rdio/base.rb', line 170 def method_missing(method,args={}) meth = method.to_s res = @json[meth] # # Maybe this should be a number # if meth =~ /_count$/ or meth =~ /^num_/ begin return res.to_i rescue Exception => e STDERR.puts "#{meth} (err) #{e}" end end return res end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
164 165 166 |
# File 'lib/rdio/base.rb', line 164 def json @json end |