Module: CanHasUpc

Defined in:
lib/can_has_upc.rb

Instance Method Summary collapse

Instance Method Details

#formatted_upc_code(len) ⇒ Object



5
6
7
# File 'lib/can_has_upc.rb', line 5

def formatted_upc_code(len)
  String(self).rjust(len, '0')[-len..-1]
end

#to_upc(len = 12) ⇒ Object



9
10
11
12
# File 'lib/can_has_upc.rb', line 9

def to_upc(len=12)
  client = XMLRPC::Client.new("www.upcdatabase.com", "/rpc")
  client.call("lookupUPC", formatted_upc_code(12))
end