Class: SvgDrawer::TextBox
Instance Attribute Summary
Attributes inherited from Base
#child_params, #inherited_params, #params
Instance Method Summary collapse
-
#height ⇒ Object
If overflow is true, but we don’t have any explicit height set, report the calculated height.
- #incomplete ⇒ Object
-
#initialize(text, params = {}) ⇒ TextBox
constructor
A new instance of TextBox.
- #width ⇒ Object
Methods inherited from Base
defaults, #draw, #ensure_complete!, #param, #param!, requires, special, #update_params!
Constructor Details
#initialize(text, params = {}) ⇒ TextBox
Returns a new instance of TextBox.
19 20 21 22 23 24 |
# File 'lib/svg_drawer/text_box.rb', line 19 def initialize(text, params = {}) super(params) @text = text.to_s.strip.gsub(/\s+/, ' ') fonts_config = SvgDrawer.configuration @config = fonts_config['default'].merge(fonts_config[param(:font)] || {}) end |
Instance Method Details
#height ⇒ Object
If overflow is true, but we don’t have any explicit height set, report the calculated height.
34 35 36 37 38 39 40 |
# File 'lib/svg_drawer/text_box.rb', line 34 def height return @height if @height ensure_complete! @height = param(:overflow) || !param(:wrap) ? param(:height, calculate_height).to_d : [param(:height, 0), calculate_height].max.to_d end |
#incomplete ⇒ Object
42 43 44 |
# File 'lib/svg_drawer/text_box.rb', line 42 def incomplete false end |
#width ⇒ Object
26 27 28 29 30 |
# File 'lib/svg_drawer/text_box.rb', line 26 def width return @width if @width ensure_complete! @width = param(:width, calculate_width).to_d end |