class Fcmpush::BatchResponse
Constants
- HAS_SYMBOL_GC
Public Instance Methods
failure_count()
click to toggle source
# File lib/fcmpush/batch_response.rb, line 26 def failure_count @failure_count ||= json.select { |i| i[:error] }.size end
inspect()
click to toggle source
# File lib/fcmpush/batch_response.rb, line 13 def inspect "#<BatchResponse response: #{response.inspect}, json: #{json}>" end
Also aliased as: to_s
json()
click to toggle source
# File lib/fcmpush/batch_response.rb, line 9 def json parsable? ? @parsed ||= parse_body(body) : nil end
parsable?()
click to toggle source
# File lib/fcmpush/batch_response.rb, line 18 def parsable? !body.nil? && !body.empty? end
success_count()
click to toggle source
# File lib/fcmpush/batch_response.rb, line 22 def success_count @success_count ||= json.length - failure_count end
Private Instance Methods
parse_body(raw_body)
click to toggle source
# File lib/fcmpush/batch_response.rb, line 32 def parse_body(raw_body) devider = raw_body.match(/(\r\n--batch_.*)\r\n/)[1] raw_body.split(devider)[1..-2].map do |response| JSON.parse(response.split("\r\n\r\n")[2], symbolize_names: HAS_SYMBOL_GC) end end