class Roku::Iap::Response
Attributes
raw_response[RW]
Public Class Methods
new(response)
click to toggle source
# File lib/roku/iap/response.rb, line 7 def initialize(response) if response.code.to_i == 200 self.raw_response = REXML::Document.new(response.body) self.raw_response.root.each do |e| underscore = e.name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').tr('-', '_').downcase self.class.class_eval("attr_accessor :#{underscore}") send "#{underscore}=", e.text.nil? ? "" : e.text end elsif response.code.to_i == 404 raise Roku::Iap::Exceptions::InvalidCredentials, "Ensure that your Roku API key is not nil!" else raise Roku::Iap::Exceptions::General, response.body end end
Public Instance Methods
successful?()
click to toggle source
# File lib/roku/iap/response.rb, line 22 def successful? self.try(:status) == "Success" end
Protected Instance Methods
try(att)
click to toggle source
# File lib/roku/iap/response.rb, line 32 def try(att) begin send "#{att}"; rescue NoMethodError ; end end