class Vindsl::DSL
Attributes
country[RW]
manufacturer[RW]
model_year[RW]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/vindsl/dsl.rb, line 7 def initialize yield self end
Public Instance Methods
regexp()
click to toggle source
# File lib/vindsl/dsl.rb, line 11 def regexp Regexp.new "^#{ wmi_regexp }[#{Alphabet::ALPHABET_WITH_NUMBERS.join}]{14}$" end
wmi_regexp()
click to toggle source
# File lib/vindsl/dsl.rb, line 15 def wmi_regexp country_prefixes = WMI.country_prefixes_for country manufacturer_prefixes = WMI.manufacturer_prefixes_for manufacturer prefix_pairs = country_prefixes.product manufacturer_prefixes ok_prefixes = prefix_pairs.select { |(c, m)| Regexp.new(c).match m} chunks = ok_prefixes.map do |(_c, pfx)| need_dots = 3 - pfx.length pfx + ('.' * need_dots) end "(#{chunks.join '|'})" end