Class: Dieses::Application::Paper::Instance

Inherits:
Geometry::Rect show all
Extended by:
Support::ClassAttribute, Forwardable
Defined in:
lib/dieses/application/paper.rb

Constant Summary

Constants inherited from Geometry::Rect

Geometry::Rect::Orientation

Instance Attribute Summary

Attributes inherited from Geometry::Rect

#height, #position, #width

Attributes inherited from Geometry::Element

#attributes, #hash

Instance Method Summary collapse

Methods included from Support::ClassAttribute

define, defines

Methods inherited from Geometry::Rect

#align, #angle, #bbox, #intersect, #orientation, #shrink, #to_s, #to_svgf, #translate

Methods included from Geometry::Rect::Predicate

#cover?, #inside?, #onto?, #outside?

Methods inherited from Geometry::Element

#attr, #classify, #eql?, #to_svg

Constructor Details

#initialize(width, height, **margin) ⇒ Instance

Returns a new instance of Instance.



97
98
99
100
# File 'lib/dieses/application/paper.rb', line 97

def initialize(width, height, **margin)
  @margin = Margin.new(**margin)
  super(Geometry::Rect.new(width, height))
end

Instance Method Details

#innerObject



102
103
104
# File 'lib/dieses/application/paper.rb', line 102

def inner
  @inner ||= shrink(width: left + right, height: top + bottom)
end

#orient(orientation) ⇒ Object



106
107
108
# File 'lib/dieses/application/paper.rb', line 106

def orient(orientation)
  self.class.new((rect = super).width, rect.height, **margin.to_h)
end

#to_hObject



110
111
112
# File 'lib/dieses/application/paper.rb', line 110

def to_h
  super.merge(margin.to_h)
end