Class: Charta::BoundingBox

Inherits:
Object
  • Object
show all
Defined in:
lib/charta/bounding_box.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(y_min, x_min, y_max, x_max) ⇒ BoundingBox

Returns a new instance of BoundingBox.



5
6
7
8
9
10
# File 'lib/charta/bounding_box.rb', line 5

def initialize(y_min, x_min, y_max, x_max)
  @y_min = y_min
  @x_min = x_min
  @y_max = y_max
  @x_max = x_max
end

Instance Attribute Details

#x_maxObject (readonly)

Returns the value of attribute x_max.



3
4
5
# File 'lib/charta/bounding_box.rb', line 3

def x_max
  @x_max
end

#x_minObject (readonly)

Returns the value of attribute x_min.



3
4
5
# File 'lib/charta/bounding_box.rb', line 3

def x_min
  @x_min
end

#y_maxObject (readonly)

Returns the value of attribute y_max.



3
4
5
# File 'lib/charta/bounding_box.rb', line 3

def y_max
  @y_max
end

#y_minObject (readonly)

Returns the value of attribute y_min.



3
4
5
# File 'lib/charta/bounding_box.rb', line 3

def y_min
  @y_min
end

Instance Method Details

#heightObject



16
17
18
# File 'lib/charta/bounding_box.rb', line 16

def height
  @y_max - @y_min
end

#svg_view_boxObject



20
21
22
# File 'lib/charta/bounding_box.rb', line 20

def svg_view_box
  [x_min, -y_max, width, height]
end

#to_aObject



24
25
26
# File 'lib/charta/bounding_box.rb', line 24

def to_a
  [[@y_min, @x_min], [@y_max, @x_max]]
end

#to_bbox_stringObject



28
29
30
# File 'lib/charta/bounding_box.rb', line 28

def to_bbox_string
  "#{@x_min}, #{@y_min}, #{x_max}, #{y_max}"
end

#widthObject



12
13
14
# File 'lib/charta/bounding_box.rb', line 12

def width
  @x_max - @x_min
end