Class: Dieses::Application::Paper::Variant
- Inherits:
-
Struct
- Object
- Struct
- Dieses::Application::Paper::Variant
- Defined in:
- lib/dieses/application/paper.rb
Instance Attribute Summary collapse
-
#floor ⇒ Object
Returns the value of attribute floor.
-
#height ⇒ Object
Returns the value of attribute height.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#type ⇒ Object
Returns the value of attribute type.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#build ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize.
Instance Attribute Details
#floor ⇒ Object
Returns the value of attribute floor
44 45 46 |
# File 'lib/dieses/application/paper.rb', line 44 def floor @floor end |
#height ⇒ Object
Returns the value of attribute height
44 45 46 |
# File 'lib/dieses/application/paper.rb', line 44 def height @height end |
#name ⇒ Object
Returns the value of attribute name
44 45 46 |
# File 'lib/dieses/application/paper.rb', line 44 def name @name end |
#scale ⇒ Object
Returns the value of attribute scale
44 45 46 |
# File 'lib/dieses/application/paper.rb', line 44 def scale @scale end |
#type ⇒ Object
Returns the value of attribute type
44 45 46 |
# File 'lib/dieses/application/paper.rb', line 44 def type @type end |
#width ⇒ Object
Returns the value of attribute width
44 45 46 |
# File 'lib/dieses/application/paper.rb', line 44 def width @width end |
Instance Method Details
#build ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dieses/application/paper.rb', line 45 def build # rubocop:disable Metrics/MethodLength,Metrics/AbcSize dim = Dim.(width, height) if scale.nil? || (short = Support.approx(dim.short * scale)) < floor short = floor scale = floor / dim.short end long = Support.approx(dim.long * scale) margin = Margin.build(dim, short: short, long: long) variant = self Paper.define_singleton_method(name) do |**kwargs| klass = Class.new(Instance) klass.type variant.type klass.variant variant.name klass.new(*dim.values, **margin.to_h.merge(**kwargs)) end end |