Class: Cura::Offsets

Inherits:
Object
  • Object
show all
Includes:
Attributes::HasAttributes, Attributes::HasInitialize
Defined in:
lib/cura/offsets.rb

Overview

The offsets of a component’s drawing area.

Instance Method Summary collapse

Methods included from Attributes::HasAttributes

included, #update_attributes

Constructor Details

#initialize(attributes = {}) ⇒ Offsets

Returns a new instance of Offsets.

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'lib/cura/offsets.rb', line 13

def initialize(attributes={})
  super

  raise ArgumentError, "component must be set" if @component.nil?
end

Instance Method Details

#bottomInteger

Get the bottom offset from the contents of a component from the bottom.

Returns:

  • (Integer)


48
49
50
# File 'lib/cura/offsets.rb', line 48

def bottom
  attribute_sum(:bottom)
end

#componentComponent

Get the component to calculate offsets for.

Returns:



# File 'lib/cura/offsets.rb', line 19

#component=(value) ⇒ Component

Set the component to calculate offsets for.

Parameters:

Returns:



29
# File 'lib/cura/offsets.rb', line 29

attribute(:component) { |value| validate_component(value) }

#heightInteger

Get the full height of offsets of a component.

Returns:

  • (Integer)


62
63
64
65
# File 'lib/cura/offsets.rb', line 62

def height
  # top + bottom
  attribute_sum(:height)
end

#leftInteger

Get the left offset from the contents of a component from the left.

Returns:

  • (Integer)


55
56
57
# File 'lib/cura/offsets.rb', line 55

def left
  attribute_sum(:left)
end

#rightInteger

Get the right offset from the contents of a component from the right.

Returns:

  • (Integer)


41
42
43
# File 'lib/cura/offsets.rb', line 41

def right
  attribute_sum(:right)
end

#topInteger

Get the top offset from the contents of a component from the top.

Returns:

  • (Integer)


34
35
36
# File 'lib/cura/offsets.rb', line 34

def top
  attribute_sum(:top)
end

#widthInteger

Get the full width of offsets of a component.

Returns:

  • (Integer)


70
71
72
73
# File 'lib/cura/offsets.rb', line 70

def width
  # left + right
  attribute_sum(:width)
end