Class: Dieses::Application::Paper::Margin

Inherits:
Struct
  • Object
show all
Defined in:
lib/dieses/application/paper.rb

Overview

in CSS margin order

Class Method Summary collapse

Class Method Details

.build(dim, short:, long:) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/dieses/application/paper.rb', line 33

def self.build(dim, short:, long:)
  kwargs = if dim.height > dim.width
             { top: long, right: short, bottom: long, left: short }
           else
             { top: short, right: long, bottom: short, left: long }
           end

  new(**kwargs)
end

.call(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/dieses/application/paper.rb', line 23

def self.call(*args)
  values = case args.size
           when 1            then Array.new(members.size, *args)
           when members.size then args
           else                   raise ArgumentError, "Incorrect number of arguments: #{args}"
           end

  new(Hash[*members.zip(values).flatten])
end