Class: ItaxCode::Encoder
- Inherits:
-
Object
- Object
- ItaxCode::Encoder
- Defined in:
- lib/itax_code/encoder.rb,
lib/itax_code/error.rb
Overview
Handles the tax code generation logic.
Constant Summary collapse
- Error =
Class.new(Error)
- InvalidBirthdateError =
Class.new(Error)
- MissingDataError =
Class.new(Error)
Instance Method Summary collapse
-
#encode ⇒ String
Computes the tax code from its components.
-
#initialize(data = {}, utils = Utils) ⇒ Encoder
constructor
A new instance of Encoder.
Constructor Details
#initialize(data = {}, utils = Utils) ⇒ Encoder
Returns a new instance of Encoder.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/itax_code/encoder.rb', line 25 def initialize(data = {}, utils = Utils) @utils = utils @surname = data[:surname] @name = data[:name] @gender = data[:gender]&.upcase @birthdate = data[:birthdate].to_s @birthplace = data[:birthplace] validate_data_presence! @birthdate = parse_birthdate! end |
Instance Method Details
#encode ⇒ String
Computes the tax code from its components.
41 42 43 44 45 46 47 48 |
# File 'lib/itax_code/encoder.rb', line 41 def encode code = encode_surname code += encode_name code += encode_birthdate code += encode_birthplace code += utils.encode_cin code code end |