Class: Eskimo::Components::Squeeze
- Inherits:
-
Object
- Object
- Eskimo::Components::Squeeze
- Defined in:
- lib/eskimo/components/squeeze.rb
Overview
Instance Method Summary collapse
-
#initialize(children) ⇒ Squeeze
constructor
A new instance of Squeeze.
- #render(**props) ⇒ Object
Constructor Details
#initialize(children) ⇒ Squeeze
Returns a new instance of Squeeze
25 26 27 28 29 30 31 |
# File 'lib/eskimo/components/squeeze.rb', line 25 def initialize(children) if !children.is_a?(Array) || block_given? raise ArgumentError.new("Squeeze works only with an Array of components") end @children = children end |
Instance Method Details
#render(**props) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/eskimo/components/squeeze.rb', line 33 def render(**props) rendered = @children.map(&props[:render]) without_blanks = rendered.reject(&:empty?) without_blanks.reject.with_index do |element, index| element == "\n" && without_blanks[index+1] == "\n" end end |