Class: Hibp::Parsers::Password

Inherits:
Object
  • Object
show all
Defined in:
lib/hibp/parsers/password.rb

Overview

Parsers::Password

Used to parse raw data and convert it to the password models

Constant Summary collapse

ROWS_SPLITTER =
"\r\n"
ATTRIBUTES_SPLITTER =
':'

Instance Method Summary collapse

Instance Method Details

#parse_response(response) ⇒ Array<Hibp::Models::Password>

Convert API response raw data to the passwords models.

Parameters:

  • response

    -

    Contains the suffix of every hash beginning with the specified prefix, followed by a count of how many times it appears in the data set

Returns:



21
22
23
24
25
# File 'lib/hibp/parsers/password.rb', line 21

def parse_response(response)
  data = response.body

  data.split(ROWS_SPLITTER).map(&method(:convert_to_password))
end