Class: Layouter::Leaf::Spacer
- Defined in:
- lib/layouter/leaf/spacer.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#max_height ⇒ Object
Returns the value of attribute max_height.
-
#max_width ⇒ Object
Returns the value of attribute max_width.
-
#min_height ⇒ Object
Returns the value of attribute min_height.
-
#min_width ⇒ Object
Returns the value of attribute min_width.
Attributes inherited from Base
Attributes inherited from Element
#calculated_height, #calculated_width
Instance Method Summary collapse
-
#initialize(weight: 1) ⇒ Spacer
constructor
A new instance of Spacer.
- #render ⇒ Object
Methods inherited from Base
Methods inherited from Element
Constructor Details
#initialize(weight: 1) ⇒ Spacer
Returns a new instance of Spacer.
7 8 9 10 11 12 13 14 15 |
# File 'lib/layouter/leaf/spacer.rb', line 7 def initialize(weight: 1) unless weight.is_a?(Numeric) raise(ArgumentError, "Weight must be a number") end raise(ArgumentError, "Weight must more than 1") if weight < 1 super(importance: EPS * weight) @min_width = @min_height = 0 @max_width = @max_height = INF end |
Instance Attribute Details
#max_height ⇒ Object
Returns the value of attribute max_height.
5 6 7 |
# File 'lib/layouter/leaf/spacer.rb', line 5 def max_height @max_height end |
#max_width ⇒ Object
Returns the value of attribute max_width.
5 6 7 |
# File 'lib/layouter/leaf/spacer.rb', line 5 def max_width @max_width end |
#min_height ⇒ Object
Returns the value of attribute min_height.
5 6 7 |
# File 'lib/layouter/leaf/spacer.rb', line 5 def min_height @min_height end |
#min_width ⇒ Object
Returns the value of attribute min_width.
5 6 7 |
# File 'lib/layouter/leaf/spacer.rb', line 5 def min_width @min_width end |
Instance Method Details
#render ⇒ Object
17 18 19 20 |
# File 'lib/layouter/leaf/spacer.rb', line 17 def render layout! ([" " * @calculated_width] * @calculated_height).join("\n") end |