class Layouter::Leaf::Base
Constants
- EPS
- INF
Attributes
importance[R]
Public Class Methods
new(importance:)
click to toggle source
Calls superclass method
Layouter::Element::new
# File lib/layouter/leaf/base.rb, line 10 def initialize(importance:) super() if !importance.is_a?(Numeric) || importance < 0 raise(ArgumentError, "Invalid importance") end @importance = importance == 0 ? EPS : importance end
Public Instance Methods
layout(width, height)
click to toggle source
# File lib/layouter/leaf/base.rb, line 18 def layout(width, height) # These layout errors could occur in the dimension not being # distributed by the parent, or if the leaf is layed our directly. raise(LayoutError.new(:width, :too_small)) if width < min_width raise(LayoutError.new(:width, :too_big)) if width > max_width raise(LayoutError.new(:height, :too_small)) if height < min_height raise(LayoutError.new(:height, :too_big)) if height > max_height @calculated_width, @calculated_height = width, height end