Files
baclight/app/models/id_card/network_logo.rb
T

32 lines
641 B
Ruby
Raw Normal View History

module IdCard
class NetworkLogo < ApplicationRecord
2026-03-13 08:47:13 -04:00
before_validation :calculate_aspect_ratio, if: :image_data_changed?
scope :defaults, -> { where(default: true) }
class << self
def medcost
defaults.where("filename LIKE ?", "%Medcost%")
end
def cigna
defaults.where("filename LIKE ?", "%Cigna%")
end
end
2026-03-03 22:53:21 -05:00
private
2026-03-03 22:53:21 -05:00
2026-03-13 08:47:13 -04:00
def calculate_aspect_ratio
image_io = StringIO.new(image_data)
width, height = FastImage.size(image_io)
image_ratio = width.to_f / height
if image_ratio
self.aspect_ratio = image_ratio.round(2)
end
2026-03-03 22:53:21 -05:00
end
2026-03-13 08:47:13 -04:00
2026-03-03 22:53:21 -05:00
end
end