lib/vindetta/decoder.rb in vindetta-0.16.0 vs lib/vindetta/decoder.rb in vindetta-0.17.0
- old
+ new
@@ -2,11 +2,11 @@
require "net/http"
require "json"
module Vindetta
class Decoder
- def self.decode_vin(vin)
+ def self.vin(vin)
Result.new(Api.get(vin)["Results"])
end
def self.plant_code(vin)
vin[10]
@@ -18,14 +18,27 @@
def self.wmi(vin)
vin[0..2]
end
- def self.vds(vin)
- vin[3..7]
+ def self.vds(vin, options = {})
+ defaults = { :check_digit => true }
+ options = defaults.merge(options)
+
+ vin[3..8].tap do |vds|
+ vds.chop! unless options[:check_digit]
+ end
end
def self.year(vin)
- decode_vin(vin).year
+ vin(vin).year
+ end
+
+ def self.vis(vin)
+ vin[9..16]
+ end
+
+ def self.production_number(vin)
+ vin[11..16]
end
end
end