Class: Archimate::DataModel::Location

Inherits:
Object
  • Object
show all
Includes:
Comparison
Defined in:
lib/archimate/data_model/location.rb

Overview

Graphical node type. It can contain child node types. This is LocationType/LocationGroup in the XSD.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Comparison

#==, #[], #dig, #each, #hash, included, #inspect, #pretty_print, #to_h

Constructor Details

#initialize(x:, y:) ⇒ Location

Returns a new instance of Location.



27
28
29
30
# File 'lib/archimate/data_model/location.rb', line 27

def initialize(x:, y:)
  @x = x.to_i
  @y = y.to_i
end

Instance Attribute Details

#xFloat (readonly)

Note:

the XSD has this as a NonNegativeInteger

The x (towards the right, associated with width) attribute from the Top,Left (i.e. 0,0) corner of the diagram to the Top, Left corner of the bounding box of the concept.

Returns:

  • (Float)


19
# File 'lib/archimate/data_model/location.rb', line 19

model_attr :x, writable: true

#yFloat (readonly)

Note:

the XSD has this as a NonNegativeInteger

The y (towards the bottom, associated with height) attribute from the Top,Left (i.e. 0,0) corner of the diagram to the Top, Left corner of the bounding box of the concept.

Returns:

  • (Float)


25
# File 'lib/archimate/data_model/location.rb', line 25

model_attr :y, writable: true

Instance Method Details

#inside?(bounds) ⇒ Boolean

Returns true if this location is inside the bounds argument

Parameters:

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/archimate/data_model/location.rb', line 38

def inside?(bounds)
  bounds.x_range.cover?(x) &&
    bounds.y_range.cover?(y)
end

#to_sObject



32
33
34
# File 'lib/archimate/data_model/location.rb', line 32

def to_s
  "Location(x: #{x}, y: #{y})"
end