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.
208 209 210 |
# File 'lib/rdio/base.rb', line 208 def initialize(json) @json = json end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, args = {}) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/rdio/base.rb', line 212 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.
206 207 208 |
# File 'lib/rdio/base.rb', line 206 def json @json end |