Class: ItaxCode::Parser
- Inherits:
-
Object
- Object
- ItaxCode::Parser
- Defined in:
- lib/itax_code/parser.rb,
lib/itax_code/error.rb
Overview
Handles the parsing logic.
Constant Summary collapse
- Error =
Class.new(Error)
- InvalidControlInternalNumberError =
Class.new(Error)
- InvalidTaxCodeError =
Class.new(Error)
- NoTaxCodeError =
Class.new(Error)
- DateTaxCodeError =
Class.new(Error)
- LENGTH =
16
Instance Method Summary collapse
-
#decode ⇒ Hash
Decodes the tax code into its components.
-
#initialize(tax_code, utils = Utils) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(tax_code, utils = Utils) ⇒ Parser
Returns a new instance of Parser.
18 19 20 21 22 23 24 25 |
# File 'lib/itax_code/parser.rb', line 18 def initialize(tax_code, utils = Utils) @tax_code = tax_code&.upcase @utils = utils raise NoTaxCodeError if @utils.blank?(@tax_code) raise InvalidTaxCodeError if @tax_code.length != LENGTH raise InvalidControlInternalNumberError if raw[:cin] != @utils.encode_cin(@tax_code) end |