Class: SilkLayout::Layout::Box

Inherits:
Object
  • Object
show all
Defined in:
lib/silk_layout/layout/box.rb

Direct Known Subclasses

AnonymousBlockBox, BlockBox, Inline, InlineBox, LineBox

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Box

Returns a new instance of Box.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/silk_layout/layout/box.rb', line 23

def initialize(node)
  @node = node
  @children = []

  @x = 0
  @y = 0
  @width = 0
  @height = 0

  @margin = {top: 0, right: 0, bottom: 0, left: 0}
  @padding = {top: 0, right: 0, bottom: 0, left: 0}
  @border = {top: 0, right: 0, bottom: 0, left: 0}
  @border_color = {
    top: nil,
    right: nil,
    bottom: nil,
    left: nil
  }
  @background_color = nil

  @explicit_width = false
  @explicit_height = false
  @flex = {}
  @display = nil
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def background_color
  @background_color
end

#borderObject

Returns the value of attribute border.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def border
  @border
end

#border_colorObject

Returns the value of attribute border_color.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def border_color
  @border_color
end

#childrenObject

Returns the value of attribute children.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def children
  @children
end

#displayObject

Returns the value of attribute display.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def display
  @display
end

#explicit_heightObject

Returns the value of attribute explicit_height.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def explicit_height
  @explicit_height
end

#explicit_widthObject

Returns the value of attribute explicit_width.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def explicit_width
  @explicit_width
end

#flexObject

Returns the value of attribute flex.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def flex
  @flex
end

#has_borderObject

Returns the value of attribute has_border.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def has_border
  @has_border
end

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def height
  @height
end

#marginObject

Returns the value of attribute margin.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def margin
  @margin
end

#nodeObject

Returns the value of attribute node.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def node
  @node
end

#paddingObject

Returns the value of attribute padding.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def padding
  @padding
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def width
  @width
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/silk_layout/layout/box.rb', line 6

def y
  @y
end

Instance Method Details

#add_child(box) ⇒ Object



49
50
51
# File 'lib/silk_layout/layout/box.rb', line 49

def add_child(box)
  @children << box
end

#border_box_heightObject



65
66
67
# File 'lib/silk_layout/layout/box.rb', line 65

def border_box_height
  height
end

#border_box_widthObject



61
62
63
# File 'lib/silk_layout/layout/box.rb', line 61

def border_box_width
  width
end

#border_box_xObject



53
54
55
# File 'lib/silk_layout/layout/box.rb', line 53

def border_box_x
  x
end

#border_box_yObject



57
58
59
# File 'lib/silk_layout/layout/box.rb', line 57

def border_box_y
  y
end