Class: Fcmpush::BatchResponse

Inherits:
Net::HTTPResponse
  • Object
show all
Defined in:
lib/fcmpush/batch_response.rb

Constant Summary collapse

HAS_SYMBOL_GC =
RUBY_VERSION > '2.2.0'

Instance Method Summary collapse

Instance Method Details

#failure_countObject



26
27
28
# File 'lib/fcmpush/batch_response.rb', line 26

def failure_count
  @failure_count ||= json.select { |i| i[:error] }.size
end

#inspectObject Also known as: to_s



13
14
15
# File 'lib/fcmpush/batch_response.rb', line 13

def inspect
  "#<BatchResponse response: #{response.inspect}, json: #{json}>"
end

#jsonObject



9
10
11
# File 'lib/fcmpush/batch_response.rb', line 9

def json
  parsable? ? @parsed ||= parse_body(body) : nil
end

#parsable?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/fcmpush/batch_response.rb', line 18

def parsable?
  !body.nil? && !body.empty?
end

#success_countObject



22
23
24
# File 'lib/fcmpush/batch_response.rb', line 22

def success_count
  @success_count ||= json.length - failure_count
end