Class: Box

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, right, bottom) ⇒ Box

Returns a new instance of Box.



7
8
9
# File 'lib/box_layout.rb', line 7

def initialize(x, y, right, bottom)
  @x, @y, @right, @bottom = x, y, right, bottom
end

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom.



6
7
8
# File 'lib/box_layout.rb', line 6

def bottom
  @bottom
end

#rightObject

Returns the value of attribute right.



6
7
8
# File 'lib/box_layout.rb', line 6

def right
  @right
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/box_layout.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/box_layout.rb', line 6

def y
  @y
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?



11
12
13
# File 'lib/box_layout.rb', line 11

def == o
  x = o.x and y = o.y and right == o.right and bottom == o.bottom
end

#hashObject



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

def hash
  [x, y, right, bottom].hash
end

#inspectObject



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

def inspect
  "Box[x=%d, y=%d, r=%d, b=%d]" % [x, y, right, bottom]
end