Module: Sashite::Qpi::Parser
- Defined in:
- lib/sashite/qpi/parser.rb
Overview
Parser for QPI (Qualified Piece Identifier) strings.
This parser splits the QPI string on the colon separator and delegates parsing of each component to the SIN and PIN libraries.
Class Method Summary collapse
-
.parse(input) ⇒ Hash
Parses a QPI string into its components.
-
.valid?(input) ⇒ Boolean
Validates a QPI string without raising an exception.
Class Method Details
.parse(input) ⇒ Hash
Parses a QPI string into its components.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sashite/qpi/parser.rb', line 27 def self.parse(input) validate_input_type(input) validate_not_empty(input) sin_string, pin_string = split_components(input) sin = parse_sin(sin_string) pin = parse_pin(pin_string) { sin: sin, pin: pin } end |
.valid?(input) ⇒ Boolean
Validates a QPI string without raising an exception.
43 44 45 46 47 48 49 50 |
# File 'lib/sashite/qpi/parser.rb', line 43 def self.valid?(input) return false unless ::String === input parse(input) true rescue Errors::Argument false end |