Logobox is a database of Czech company logos. Currently it contains more than 13 000 logos.
This gem knows how to construct right URLs to those logos. It can also check if logo for company is present on Logobox. All you need is ICO of the company.
Add this line to your application's Gemfile:
gem 'logobox'
Logobox has 3 public methods:
Returns true if logo exists on logobox. If ICO is invalid or logo doesn't exist on logobox returns false. Does actual http request to retrieve this information.
Logobox.logo_exists?(12345678) # Invalid ico
=> false
Generates url for logo by given ICO. Logobox provides 3 sizes of logos. You can pick the size by providing second argument. It can be :small/:medium/:big. Default is :medium.
Logobox.generate_logo_url(12345678)
=> "http://www.logobox.cz/getimage.ashx?id=CZ12345678"
Logobox.generate_logo_url(12345678, :small)
=> "http://www.logobox.cz/getimage.ashx?id=CZ12345678&size=small"
Works same as non bang method but if ICO is invalid or logo doesn't exist on Logobox it raises ArgumentError
or Logobox::LogoNotFound
. Again you can pick size with second optional argument.
Logobox.generate_logo_url!(12345678)
=> ArgumentError: ico is invalid
Logobox.generate_logo_url!(29137420)
=> Logobox::LogoNotFound: logo does not exists
Logobox.generate_logo_url!(27082440)
=> "http://www.logobox.cz/getimage.ashx?id=CZ27082440"
class Company < ActiveRecord::Base
...
def logo_url
Logobox.generate_logo_url(self.ico, :medium)
end
...
end
<%= image_tag(@contact.logo_url) %>