Class: Editframe::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/editframe/util.rb

Class Method Summary collapse

Class Method Details

.dimensions_for_aspect_ratio(aspect_ratio, hd = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/editframe/util.rb', line 5

def self.dimensions_for_aspect_ratio(aspect_ratio, hd = false)
  case aspect_ratio
  when '1:1'
    hd ? { :width => 1024, :height => 1024 } :  { :width => 700, :height => 700 }
  when '16:9'
    hd ? { :width => 1920, :height => 1080 } :  { :width => 1024, :height => 576 }
  when '5:4'
    hd ? { :width => 1280, :height => 1024 } :  { :width => 640, :height => 512 }
  when '4:5'
    hd ? { :width => 1024, :height => 1280 } :  { :width => 512, :height => 640 }
  when '9:16'
    hd ? { :width => 1080, :height => 1920 } :  { :width => 576, :height => 1024 }
  end
end

.dimensions_for_resolution(resolution = '700x700') ⇒ Object



20
21
22
23
24
# File 'lib/editframe/util.rb', line 20

def self.dimensions_for_resolution(resolution = '700x700')
  return {} unless !resolution.nil?
  values = resolution.split('x')
  { width: values[0].to_i, height: values[1].to_i }
end

.uuidObject



26
27
28
# File 'lib/editframe/util.rb', line 26

def self.uuid
  SecureRandom.uuid.slice(0,6)
end