Class: Archimate::DataModel::Bounds

Inherits:
ArchimateNode show all
Defined in:
lib/archimate/data_model/bounds.rb

Instance Attribute Summary

Attributes inherited from ArchimateNode

#parent_attribute_name, #struct_instance_variables

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArchimateNode

#ancestors, #build_index, #clone, #compact!, #delete, #diff, #dup, #element_by_id, #id, #in_model, #in_model=, #initialize, #parent, #parent=, #path, #primitive?, #referenced_identified_nodes, #set, #with

Constructor Details

This class inherits a constructor from Archimate::DataModel::ArchimateNode

Class Method Details

.zeroObject



10
11
12
# File 'lib/archimate/data_model/bounds.rb', line 10

def self.zero
  Archimate::DataModel::Bounds.new(x: 0, y: 0, width: 0, height: 0)
end

Instance Method Details

#bottomObject



30
31
32
# File 'lib/archimate/data_model/bounds.rb', line 30

def bottom
  top + height
end

#inside?(other) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
# File 'lib/archimate/data_model/bounds.rb', line 62

def inside?(other)
  left > other.left &&
    right < other.right &&
    top > other.top &&
    bottom < other.bottom
end

#is_above?(other) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/archimate/data_model/bounds.rb', line 42

def is_above?(other)
  bottom < other.top
end

#is_below?(other) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/archimate/data_model/bounds.rb', line 46

def is_below?(other)
  top > other.bottom
end

#is_left_of?(other) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/archimate/data_model/bounds.rb', line 54

def is_left_of?(other)
  right < other.left
end

#is_right_of?(other) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/archimate/data_model/bounds.rb', line 50

def is_right_of?(other)
  left > other.right
end

#leftObject



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

def left
  x || 0
end

#reduced_by(val) ⇒ Object



58
59
60
# File 'lib/archimate/data_model/bounds.rb', line 58

def reduced_by(val)
  Bounds.new(x: left + val, y: top + val, width: width - val * 2, height: height - val * 2)
end

#rightObject



34
35
36
# File 'lib/archimate/data_model/bounds.rb', line 34

def right
  left + width
end

#to_sObject



14
15
16
# File 'lib/archimate/data_model/bounds.rb', line 14

def to_s
  "Bounds(x: #{x}, y: #{y}, width: #{width}, height: #{height})"
end

#topObject



26
27
28
# File 'lib/archimate/data_model/bounds.rb', line 26

def top
  y || 0
end

#x_rangeObject



18
19
20
# File 'lib/archimate/data_model/bounds.rb', line 18

def x_range
  Range.new(left, right)
end

#y_rangeObject



22
23
24
# File 'lib/archimate/data_model/bounds.rb', line 22

def y_range
  Range.new(top, bottom)
end