module ItaxCode

Constants

VERSION

Public Class Methods

decode(tax_code) click to toggle source

This method decodes tax code in its components.

@example

ItaxCode.decode("CCCFBA85D03L219P")

@param [String] tax_code The user tax code

@return [Hash]

# File lib/itax_code.rb, line 42
def decode(tax_code)
  Parser.new(tax_code).decode
end
encode(data) click to toggle source

This method encodes user tax code.

@example

ItaxCode.encode({
  surname:    [String]
  name:       [String]
  gender:     [String]
  birthdate:  [Date, DateTime, Time]
  birthplace: [String]
})

@param [Hash] data The user data attributes

@return [String]

# File lib/itax_code.rb, line 27
def encode(data)
  Encoder.new(data).encode
end
valid?(tax_code, data) click to toggle source

This method check given tax code validity against new one encoded from user informations.

@example

ItaxCode.valid?(tax_code [String], {
   surname:    [String]
   name:       [String]
   gender:     [String]
   birthdate:  [Date, DateTime, Time]
   birthplace: [String]
})

@return [true, false]

# File lib/itax_code.rb, line 62
def valid?(tax_code, data)
  Validator.new(data).valid?(tax_code)
end