class Parsers::RemainingMessagesResponse

Attributes

error[RW]
pending_messages[RW]
remaining_messages[RW]
success[RW]

Public Class Methods

new(body) click to toggle source
# File lib/slybroadcast/parsers/remaining_messages_response.rb, line 8
def initialize(body)
  response_parse(body)
end

Public Instance Methods

failed?() click to toggle source
# File lib/slybroadcast/parsers/remaining_messages_response.rb, line 12
def failed?
  not success?
end
success?() click to toggle source
# File lib/slybroadcast/parsers/remaining_messages_response.rb, line 16
def success?
  success
end

Private Instance Methods

response_parse(body) click to toggle source
# File lib/slybroadcast/parsers/remaining_messages_response.rb, line 22
def response_parse(body)
  response = body.split("\n")
  @success = response[0].include?('remaining')

  unless success
    @error = response[1].strip
  else
    @remaining_messages = response[0].gsub(/[^0-9]/i, '').strip
    @pending_messages = response[1].gsub(/[^0-9]/i, '').strip
  end
end