Class: SilkLayout::Layout::Box
- Inherits:
-
Object
- Object
- SilkLayout::Layout::Box
- Defined in:
- lib/silk_layout/layout/box.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#background_color ⇒ Object
Returns the value of attribute background_color.
-
#border ⇒ Object
Returns the value of attribute border.
-
#border_color ⇒ Object
Returns the value of attribute border_color.
-
#children ⇒ Object
Returns the value of attribute children.
-
#display ⇒ Object
Returns the value of attribute display.
-
#explicit_height ⇒ Object
Returns the value of attribute explicit_height.
-
#explicit_width ⇒ Object
Returns the value of attribute explicit_width.
-
#flex ⇒ Object
Returns the value of attribute flex.
-
#has_border ⇒ Object
Returns the value of attribute has_border.
-
#height ⇒ Object
Returns the value of attribute height.
-
#image_resource ⇒ Object
Returns the value of attribute image_resource.
-
#image_source ⇒ Object
Returns the value of attribute image_source.
-
#intrinsic_height ⇒ Object
Returns the value of attribute intrinsic_height.
-
#intrinsic_width ⇒ Object
Returns the value of attribute intrinsic_width.
-
#margin ⇒ Object
Returns the value of attribute margin.
-
#node ⇒ Object
Returns the value of attribute node.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#replaced ⇒ Object
Returns the value of attribute replaced.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #add_child(box) ⇒ Object
- #border_box_height ⇒ Object
- #border_box_width ⇒ Object
- #border_box_x ⇒ Object
- #border_box_y ⇒ Object
- #content_box_height ⇒ Object
- #content_box_width ⇒ Object
- #content_box_x ⇒ Object
- #content_box_y ⇒ Object
- #image? ⇒ Boolean
- #image_path ⇒ Object
-
#initialize(node) ⇒ Box
constructor
A new instance of Box.
- #replaced? ⇒ Boolean
Constructor Details
#initialize(node) ⇒ Box
Returns a new instance of Box.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/silk_layout/layout/box.rb', line 28 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 @replaced = false @image_source = nil @image_resource = nil @intrinsic_width = nil @intrinsic_height = nil end |
Instance Attribute Details
#background_color ⇒ Object
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 |
#border ⇒ Object
Returns the value of attribute border.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def border @border end |
#border_color ⇒ Object
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 |
#children ⇒ Object
Returns the value of attribute children.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def children @children end |
#display ⇒ Object
Returns the value of attribute display.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def display @display end |
#explicit_height ⇒ Object
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_width ⇒ Object
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 |
#flex ⇒ Object
Returns the value of attribute flex.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def flex @flex end |
#has_border ⇒ Object
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 |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def height @height end |
#image_resource ⇒ Object
Returns the value of attribute image_resource.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def image_resource @image_resource end |
#image_source ⇒ Object
Returns the value of attribute image_source.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def image_source @image_source end |
#intrinsic_height ⇒ Object
Returns the value of attribute intrinsic_height.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def intrinsic_height @intrinsic_height end |
#intrinsic_width ⇒ Object
Returns the value of attribute intrinsic_width.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def intrinsic_width @intrinsic_width end |
#margin ⇒ Object
Returns the value of attribute margin.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def margin @margin end |
#node ⇒ Object
Returns the value of attribute node.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def node @node end |
#padding ⇒ Object
Returns the value of attribute padding.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def padding @padding end |
#replaced ⇒ Object
Returns the value of attribute replaced.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def replaced @replaced end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/silk_layout/layout/box.rb', line 6 def x @x end |
#y ⇒ Object
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
59 60 61 |
# File 'lib/silk_layout/layout/box.rb', line 59 def add_child(box) @children << box end |
#border_box_height ⇒ Object
75 76 77 |
# File 'lib/silk_layout/layout/box.rb', line 75 def border_box_height height end |
#border_box_width ⇒ Object
71 72 73 |
# File 'lib/silk_layout/layout/box.rb', line 71 def border_box_width width end |
#border_box_x ⇒ Object
63 64 65 |
# File 'lib/silk_layout/layout/box.rb', line 63 def border_box_x x end |
#border_box_y ⇒ Object
67 68 69 |
# File 'lib/silk_layout/layout/box.rb', line 67 def border_box_y y end |
#content_box_height ⇒ Object
91 92 93 |
# File 'lib/silk_layout/layout/box.rb', line 91 def content_box_height [height - border[:top] - border[:bottom] - padding[:top] - padding[:bottom], 0].max end |
#content_box_width ⇒ Object
87 88 89 |
# File 'lib/silk_layout/layout/box.rb', line 87 def content_box_width [width - border[:left] - border[:right] - padding[:left] - padding[:right], 0].max end |
#content_box_x ⇒ Object
79 80 81 |
# File 'lib/silk_layout/layout/box.rb', line 79 def content_box_x x + border[:left] + padding[:left] end |
#content_box_y ⇒ Object
83 84 85 |
# File 'lib/silk_layout/layout/box.rb', line 83 def content_box_y y + border[:top] + padding[:top] end |
#image? ⇒ Boolean
99 100 101 |
# File 'lib/silk_layout/layout/box.rb', line 99 def image? !image_resource.nil? end |
#image_path ⇒ Object
103 104 105 |
# File 'lib/silk_layout/layout/box.rb', line 103 def image_path image_resource&.path end |
#replaced? ⇒ Boolean
95 96 97 |
# File 'lib/silk_layout/layout/box.rb', line 95 def replaced? replaced end |