Module: ItaxCode

Defined in:
lib/itax_code.rb,
lib/itax_code/error.rb,
lib/itax_code/utils.rb,
lib/itax_code/parser.rb,
lib/itax_code/encoder.rb,
lib/itax_code/omocode.rb,
lib/itax_code/version.rb,
lib/itax_code/transliterator.rb

Defined Under Namespace

Modules: Utils Classes: Encoder, Omocode, Parser, Transliterator

Constant Summary collapse

Error =
Class.new(StandardError)
VERSION =
"2.0.5"

Class Method Summary collapse

Class Method Details

.decode(tax_code) ⇒ Hash

Decodes the tax code in its components.

Parameters:

  • tax_code (String)

    The user tax code

Returns:

  • (Hash)


31
32
33
# File 'lib/itax_code.rb', line 31

def decode(tax_code)
  Parser.new(tax_code).decode
end

.encode(data) ⇒ String

Encodes the user tax code.

Parameters:

  • data (Hash)

    The user attributes

Options Hash (data):

  • :surname (String)
  • :name (String)
  • :gender (String)
  • :birthdate (String, Date)
  • :birthplace (String)

Returns:

  • (String)


22
23
24
# File 'lib/itax_code.rb', line 22

def encode(data)
  Encoder.new(data).encode
end

.valid?(tax_code) ⇒ Boolean

Checks the given tax code validity.

Parameters:

  • tax_code (String)

    The user tax code

Returns:

  • (Boolean)


40
41
42
43
44
45
# File 'lib/itax_code.rb', line 40

def valid?(tax_code)
  decode(tax_code)
  true
rescue Parser::Error
  false
end