class Wowapi::ResponseData
Every ModuleClass inherits from this object, so GuildClass, AchievementClass etc. ResponseData
class inherits from OpenStruct which makes it easy to define arbitrary fields, using a Hash (so a default response object) www.ruby-doc.org/stdlib-2.0/libdoc/ostruct/rdoc/OpenStruct.html
Attributes
raw[RW]
Raw holds the response Hash, untouched
Public Class Methods
new(data={})
click to toggle source
Calls superclass method
# File lib/wowapi/response_data.rb, line 13 def initialize(data={}) unless data.is_a?(Hash) raise ArgumentError, 'Data has to be passed as a Hash object.' end super end
Public Instance Methods
as_json(options={})
click to toggle source
# File lib/wowapi/response_data.rb, line 32 def as_json(options={}) @table end
from_json(data)
click to toggle source
Create a object of suitable class e.g.: guild = api.guild … guild = guild.from_json(data)
# File lib/wowapi/response_data.rb, line 28 def from_json(data) self.class.new(JSON.parse(data)) end
to_json(*options)
click to toggle source
Return raw data (retrieved by Blizzard servers)
# File lib/wowapi/response_data.rb, line 21 def to_json(*options) as_json(*options).to_json(*options) end