Class: Diagrams::Box

Inherits:
Sized show all
Defined in:
lib/maruku/ext/diagrams/structures.rb

Instance Attribute Summary collapse

Attributes inherited from Sized

#hs, #links, #vs

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ Box

Returns a new instance of Box.



96
97
98
99
100
# File 'lib/maruku/ext/diagrams/structures.rb', line 96

def initialize(x,y,width,height)
	super()
	@x,@y,@width,@height = x,y,width,height
	@aligned = {:l=>[],:t=>[],:b=>[],:r=>[]}
end

Instance Attribute Details

#alignedObject

Returns the value of attribute aligned.



90
91
92
# File 'lib/maruku/ext/diagrams/structures.rb', line 90

def aligned
  @aligned
end

#contentObject

Returns the value of attribute content.



88
89
90
# File 'lib/maruku/ext/diagrams/structures.rb', line 88

def content
  @content
end

#heightObject

Returns the value of attribute height.



87
88
89
# File 'lib/maruku/ext/diagrams/structures.rb', line 87

def height
  @height
end

#v_brObject

variables for top-left and bottom-right



93
94
95
# File 'lib/maruku/ext/diagrams/structures.rb', line 93

def v_br
  @v_br
end

#v_tlObject

variables for top-left and bottom-right



93
94
95
# File 'lib/maruku/ext/diagrams/structures.rb', line 93

def v_tl
  @v_tl
end

#widthObject

Returns the value of attribute width.



87
88
89
# File 'lib/maruku/ext/diagrams/structures.rb', line 87

def width
  @width
end

#xObject

Returns the value of attribute x.



87
88
89
# File 'lib/maruku/ext/diagrams/structures.rb', line 87

def x
  @x
end

#yObject

Returns the value of attribute y.



87
88
89
# File 'lib/maruku/ext/diagrams/structures.rb', line 87

def y
  @y
end

Instance Method Details

pos: position touching this from: other



104
105
106
107
108
109
110
# File 'lib/maruku/ext/diagrams/structures.rb', line 104

def link_direction(pos, inc)
	if pos.x == @x then return :W end
	if pos.x == @x+@width-1 then return :E end
	if pos.y == @y then return :N end
	if pos.y == @y+@height-1 then return :S end
	raise "Strange #{pos.inspect}: "+self.inspect
end