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/requests.rb
Defined Under Namespace
Modules: Format, Request, Utility
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.
4 5 6 7 8 9 10 |
# File 'lib/vat_check.rb', line 4 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.
2 3 4 |
# File 'lib/vat_check.rb', line 2 def regex @regex end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
2 3 4 |
# File 'lib/vat_check.rb', line 2 def response @response end |
#vies ⇒ Object (readonly)
Returns the value of attribute vies.
2 3 4 |
# File 'lib/vat_check.rb', line 2 def vies @vies end |
#vies_available ⇒ Object (readonly)
Returns the value of attribute vies_available.
2 3 4 |
# File 'lib/vat_check.rb', line 2 def vies_available @vies_available end |
Instance Method Details
#exists? ⇒ Boolean
18 19 20 |
# File 'lib/vat_check.rb', line 18 def exists? return @vies end |
#valid? ⇒ Boolean
12 13 14 15 16 |
# File 'lib/vat_check.rb', line 12 def valid? return false unless @regex return @regex unless @vies_available return @vies end |