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



13
14
15
16
17
18
# File 'lib/cura/attributes/has_coordinates.rb', line 13

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 20

#x=(value) ⇒ Integer

Set the X coordinate of this object.

Parameters:

  • value (#to_i)

Returns:

  • (Integer)


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

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

#yInteger

Get the Y coordinate of this object.

Returns:

  • (Integer)


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

#y=(value) ⇒ Integer

Set the Y coordinate of this object.

Parameters:

  • value (#to_i)

Returns:

  • (Integer)


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

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