lib/valvat.rb in valvat-0.7.0 vs lib/valvat.rb in valvat-0.7.1

- old
+ new

@@ -1,58 +1,12 @@ -class Valvat - def initialize(raw) - @raw = Valvat::Utils.normalize(raw || "") - @vat_country_code, @to_s_wo_country = to_a - end +require 'valvat/local' +require 'valvat/lookup' +require 'valvat/lookup/request' +require 'valvat/lookup/request_with_id' +require 'active_model/validations/valvat_validator' if defined?(ActiveModel) - attr_reader :raw, :vat_country_code, :to_s_wo_country - - def blank? - raw.nil? || raw.strip == "" - end - - def valid? - Valvat::Syntax.validate(self) - end - - def valid_checksum? - Valvat::Checksum.validate(self) - end - +class Valvat def exists?(options={}) Valvat::Lookup.validate(self, options) end alias_method :exist?, :exists? - - def iso_country_code - Valvat::Utils.vat_country_to_iso_country(vat_country_code) - end - - def european? - Valvat::Utils::EU_COUNTRIES.include?(iso_country_code) - end - - def to_a - Valvat::Utils.split(raw) - end - - def to_s - raw - end - - def inspect - "#<Valvat #{[raw, iso_country_code].compact.join(" ")}>" - end end - -def Valvat(vat) - vat.is_a?(Valvat) ? vat : Valvat.new(vat) -end - -require 'valvat/utils' -require 'valvat/syntax' -require 'valvat/checksum' -require 'valvat/lookup' -require 'valvat/lookup/request' -require 'valvat/lookup/request_with_id' -require 'valvat/version' -require 'active_model/validations/valvat_validator' if defined?(ActiveModel)