class ONIX::Territory
Public Class Methods
region_to_countries(region)
click to toggle source
@param [String] region @return [Array<String>]
# File lib/onix/territory.rb, line 49 def self.region_to_countries(region) case region when "WORLD" CountryCode.list when "ECZ" ["AT", "BE", "CY", "EE", "FI", "FR", "DE", "ES", "GR", "IE", "IT", "LU", "MT", "NL", "PT", "SI", "SK", "AD", "MC", "SM", "VA", "ME"] else [] end end
worldwide?(countries)
click to toggle source
@return [Boolean]
# File lib/onix/territory.rb, line 62 def self.worldwide?(countries) (countries & CountryCode.list).length == CountryCode.list.length end
Public Instance Methods
countries()
click to toggle source
all countries array @return [Array<String>]
# File lib/onix/territory.rb, line 13 def countries countries = [] if @countries_included countries += @countries_included.split(" ") end if @regions_included countries += @regions_included.split(" ").map { |region| self.class.region_to_countries(region) }.flatten.uniq end if @countries_excluded countries -= @countries_excluded.split(" ") end if @regions_excluded countries -= @regions_excluded.split(" ").map { |region| self.class.region_to_countries(region) }.flatten.uniq end countries.uniq.sort end
countries=(v)
click to toggle source
@param [Array<String>] v
# File lib/onix/territory.rb, line 37 def countries= v if (v.uniq & CountryCode.list).length == CountryCode.list.length @regions_included = "WORLD" else @countries_included = v.uniq.join(" ") end end
worldwide?()
click to toggle source
has worldwide rights ? @return [Boolean]
# File lib/onix/territory.rb, line 32 def worldwide? self.class.worldwide?(self.countries) end