Class: VatCheck
- Inherits:
-
Object
- Object
- VatCheck
- Defined in:
- lib/vat_check.rb,
lib/vat_check/format.rb,
lib/vat_check/utility.rb,
lib/vat_check/version.rb,
lib/vat_check/requests.rb
Defined Under Namespace
Modules: Format, Request, Utility
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#vies ⇒ Object
readonly
Returns the value of attribute vies.
-
#vies_available ⇒ Object
readonly
Returns the value of attribute vies_available.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(vat) ⇒ VatCheck
constructor
A new instance of VatCheck.
- #valid? ⇒ Boolean
Constructor Details
#initialize(vat) ⇒ VatCheck
Returns a new instance of VatCheck.
9 10 11 12 13 14 15 |
# File 'lib/vat_check.rb', line 9 def initialize(vat) @vat = vat @regex = VatCheck::Format.valid?(@vat) @response = @regex ? VatCheck::Request.lookup(@vat) : {} @vies_available = @response.has_key?(:valid) @vies = @vies_available ? @response[:valid] : false end |
Instance Attribute Details
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
7 8 9 |
# File 'lib/vat_check.rb', line 7 def regex @regex end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/vat_check.rb', line 7 def response @response end |
#vies ⇒ Object (readonly)
Returns the value of attribute vies.
7 8 9 |
# File 'lib/vat_check.rb', line 7 def vies @vies end |
#vies_available ⇒ Object (readonly)
Returns the value of attribute vies_available.
7 8 9 |
# File 'lib/vat_check.rb', line 7 def vies_available @vies_available end |
Instance Method Details
#exists? ⇒ Boolean
23 24 25 |
# File 'lib/vat_check.rb', line 23 def exists? return @vies end |
#valid? ⇒ Boolean
17 18 19 20 21 |
# File 'lib/vat_check.rb', line 17 def valid? return false unless @regex return @regex unless @vies_available return @vies end |