Module: Cura::Attributes::HasCoordinates

Includes:
HasAttributes
Included in:
HasRelativeCoordinates, Cursor, Window
Defined in:
lib/cura/attributes/has_coordinates.rb

Overview

Adds the ‘x` and `y` attributes.

Instance Method Summary collapse

Methods included from HasAttributes

included, #update_attributes

Instance Method Details

#initialize(attributes = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/cura/attributes/has_coordinates.rb', line 9

def initialize(attributes={})
  @x = 0 unless instance_variable_defined?(:@x)
  @y = 0 unless instance_variable_defined?(:@y)

  super
end

#xInteger

Get the X coordinate of this object.

Returns:

  • (Integer)


# File 'lib/cura/attributes/has_coordinates.rb', line 16

#x=(value) ⇒ Integer

Set the X coordinate of this object.

Parameters:

  • value (#to_i)

Returns:

  • (Integer)


27
# File 'lib/cura/attributes/has_coordinates.rb', line 27

attribute(:x) { |value| value.to_i }

#yInteger

Get the Y coordinate of this object.

Returns:

  • (Integer)


# File 'lib/cura/attributes/has_coordinates.rb', line 29

#y=(value) ⇒ Integer

Set the Y coordinate of this object.

Parameters:

  • value (#to_i)

Returns:

  • (Integer)


40
# File 'lib/cura/attributes/has_coordinates.rb', line 40

attribute(:y) { |value| value.to_i }