Class: Valvat
- Inherits:
-
Object
- Object
- Valvat
- Defined in:
- lib/valvat.rb,
lib/valvat/error.rb,
lib/valvat/utils.rb,
lib/valvat/lookup.rb,
lib/valvat/syntax.rb,
lib/valvat/options.rb,
lib/valvat/version.rb,
lib/valvat/checksum.rb,
lib/valvat/checksum/at.rb,
lib/valvat/checksum/be.rb,
lib/valvat/checksum/bg.rb,
lib/valvat/checksum/cy.rb,
lib/valvat/checksum/de.rb,
lib/valvat/checksum/dk.rb,
lib/valvat/checksum/ee.rb,
lib/valvat/checksum/es.rb,
lib/valvat/checksum/fi.rb,
lib/valvat/checksum/fr.rb,
lib/valvat/checksum/gb.rb,
lib/valvat/checksum/gr.rb,
lib/valvat/checksum/hr.rb,
lib/valvat/checksum/hu.rb,
lib/valvat/checksum/ie.rb,
lib/valvat/checksum/it.rb,
lib/valvat/checksum/lt.rb,
lib/valvat/checksum/lu.rb,
lib/valvat/checksum/mt.rb,
lib/valvat/checksum/nl.rb,
lib/valvat/checksum/pl.rb,
lib/valvat/checksum/pt.rb,
lib/valvat/checksum/ro.rb,
lib/valvat/checksum/se.rb,
lib/valvat/checksum/si.rb,
lib/valvat/lookup/base.rb,
lib/valvat/lookup/hmrc.rb,
lib/valvat/lookup/vies.rb,
lib/valvat/configuration.rb,
lib/valvat/hmrc/access_token.rb
Defined Under Namespace
Modules: Checksum, HMRC, Syntax, Utils Classes: Configuration, Lookup, LookupError, Options
Constant Summary collapse
- Error =
Class.new(RuntimeError)
- MaintenanceError =
Class.new(LookupError)
Class.new(MaintenanceError)
Class.new(MaintenanceError)
- Timeout =
Class.new(LookupError)
- InvalidRequester =
Class.new(LookupError)
- BlockedError =
Class.new(LookupError)
- RateLimitError =
Class.new(LookupError)
- UnknownLookupError =
Class.new(LookupError)
- HTTPError =
Class.new(LookupError)
- AuthorizationError =
Class.new(LookupError)
- VERSION =
'2.0.1'
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#to_s_wo_country ⇒ Object
readonly
Returns the value of attribute to_s_wo_country.
-
#vat_country_code ⇒ Object
readonly
Returns the value of attribute vat_country_code.
Class Method Summary collapse
-
.config ⇒ Object
Read-only access to config.
-
.configure(options) ⇒ Object
Configuration options should be set by passing a hash:.
- .Options(options) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #blank? ⇒ Boolean
-
#european? ⇒ Boolean
TODO: Remove method / not in use.
- #exists?(options = {}) ⇒ Boolean (also: #exist?)
-
#initialize(raw) ⇒ Valvat
constructor
A new instance of Valvat.
- #inspect ⇒ Object
- #iso_country_code ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
- #valid_checksum? ⇒ Boolean
Constructor Details
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
19 20 21 |
# File 'lib/valvat.rb', line 19 def raw @raw end |
#to_s_wo_country ⇒ Object (readonly)
Returns the value of attribute to_s_wo_country.
19 20 21 |
# File 'lib/valvat.rb', line 19 def to_s_wo_country @to_s_wo_country end |
#vat_country_code ⇒ Object (readonly)
Returns the value of attribute vat_country_code.
19 20 21 |
# File 'lib/valvat.rb', line 19 def vat_country_code @vat_country_code end |
Class Method Details
.config ⇒ Object
Read-only access to config
18 19 20 |
# File 'lib/valvat/configuration.rb', line 18 def self.config Configuration.instance end |
.configure(options) ⇒ Object
Configuration options should be set by passing a hash:
Valvat.configure(
uk: { client_id: '<client_id>', client_secret: '<client_secret>' }
)
13 14 15 |
# File 'lib/valvat/configuration.rb', line 13 def self.configure() Configuration.instance.configure() unless .nil? end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
57 58 59 |
# File 'lib/valvat.rb', line 57 def ==(other) raw == other.raw end |
#blank? ⇒ Boolean
21 22 23 |
# File 'lib/valvat.rb', line 21 def blank? raw.nil? || raw.strip == '' end |
#european? ⇒ Boolean
TODO: Remove method / not in use
43 44 45 46 47 |
# File 'lib/valvat.rb', line 43 def european? puts 'DEPRECATED: #european? is deprecated. Instead access Valvat::Utils::EU_MEMBER_STATES directly.' Valvat::Utils::EU_MEMBER_STATES.include?(iso_country_code) end |
#exists?(options = {}) ⇒ Boolean Also known as: exist?
33 34 35 |
# File 'lib/valvat.rb', line 33 def exists?( = {}) Valvat::Lookup.validate(self, ) end |
#inspect ⇒ Object
62 63 64 |
# File 'lib/valvat.rb', line 62 def inspect "#<Valvat #{[raw, iso_country_code].compact.join(' ')}>" end |
#iso_country_code ⇒ Object
38 39 40 |
# File 'lib/valvat.rb', line 38 def iso_country_code Valvat::Utils.vat_country_to_iso_country(vat_country_code) end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/valvat.rb', line 53 def to_s raw end |