class Valvat
Constants
- BlockedError
- Error
- HTTPError
- InvalidRequester
- MaintenanceError
- RateLimitError
- Timeout
- UnknownLookupError
- VERSION
Attributes
raw[R]
to_s_wo_country[R]
vat_country_code[R]
Public Class Methods
Options(options)
click to toggle source
# File lib/valvat/options.rb, line 28 def self.Options(options) options.is_a?(Valvat::Options) ? options : Valvat::Options.new(options) end
config()
click to toggle source
Read-only access to config
# File lib/valvat/configuration.rb, line 18 def self.config Configuration.instance end
configure(options)
click to toggle source
Configuration
options should be set by passing a hash:
Valvat.configure( uk: true )
# File lib/valvat/configuration.rb, line 13 def self.configure(options) Configuration.instance.configure(options) unless options.nil? end
new(raw)
click to toggle source
# File lib/valvat.rb, line 14 def initialize(raw) @raw = Valvat::Utils.normalize(raw || '') @vat_country_code, @to_s_wo_country = to_a end
Public Instance Methods
==(other)
click to toggle source
# File lib/valvat.rb, line 57 def ==(other) raw == other.raw end
Also aliased as: eql?
blank?()
click to toggle source
# File lib/valvat.rb, line 21 def blank? raw.nil? || raw.strip == '' end
european?()
click to toggle source
TODO: Remove method / not in use
# 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 = {})
click to toggle source
# File lib/valvat.rb, line 33 def exists?(options = {}) Valvat::Lookup.validate(self, options) end
Also aliased as: exist?
inspect()
click to toggle source
# File lib/valvat.rb, line 62 def inspect "#<Valvat #{[raw, iso_country_code].compact.join(' ')}>" end
iso_country_code()
click to toggle source
# File lib/valvat.rb, line 38 def iso_country_code Valvat::Utils.vat_country_to_iso_country(vat_country_code) end
to_a()
click to toggle source
# File lib/valvat.rb, line 49 def to_a Valvat::Utils.split(raw) end
to_s()
click to toggle source
# File lib/valvat.rb, line 53 def to_s raw end
valid?()
click to toggle source
# File lib/valvat.rb, line 25 def valid? Valvat::Syntax.validate(self) end
valid_checksum?()
click to toggle source
# File lib/valvat.rb, line 29 def valid_checksum? Valvat::Checksum.validate(self) end