Module: Ravvi
- Defined in:
- lib/ravvi.rb
Overview
Ad format presets and safe-area helpers.
Companion utilities for Ravvi (https://ravvi.ai), an AI ad generator.
Defined Under Namespace
Classes: Format
Constant Summary collapse
- VERSION =
"0.1.0"- FORMATS =
{ "instagram_reels" => Format.new("instagram_reels", "instagram", 1080, 1920, 90), "instagram_feed" => Format.new("instagram_feed", "instagram", 1080, 1350, 60), "tiktok_infeed" => Format.new("tiktok_infeed", "tiktok", 1080, 1920, 60), "youtube_shorts" => Format.new("youtube_shorts", "youtube", 1080, 1920, 60), "youtube_instream" => Format.new("youtube_instream", "youtube", 1920, 1080, 30), "facebook_feed" => Format.new("facebook_feed", "facebook", 1080, 1080, 60), "facebook_story" => Format.new("facebook_story", "facebook", 1080, 1920, 15), "linkedin_feed" => Format.new("linkedin_feed", "linkedin", 1200, 628, 30), "x_feed" => Format.new("x_feed", "x", 1200, 675, 140) }.freeze
Class Method Summary collapse
-
.formats_for(platform) ⇒ Object
Every known placement for a platform, widest aspect first.
-
.safe_area(format, top: 0.14, bottom: 0.20) ⇒ Object
Pixel box that stays clear of the platform's UI chrome.
Class Method Details
.formats_for(platform) ⇒ Object
Every known placement for a platform, widest aspect first.
29 30 31 32 33 |
# File 'lib/ravvi.rb', line 29 def self.formats_for(platform) FORMATS.values .select { |f| f.platform == platform.to_s.downcase } .sort_by { |f| -(f.width.to_f / f.height) } end |
.safe_area(format, top: 0.14, bottom: 0.20) ⇒ Object
Pixel box that stays clear of the platform's UI chrome.
36 37 38 39 40 |
# File 'lib/ravvi.rb', line 36 def self.safe_area(format, top: 0.14, bottom: 0.20) y0 = (format.height * top).round y1 = (format.height * (1 - bottom)).round { x: 0, y: y0, width: format.width, height: y1 - y0 } end |