Class: PhlexUI::AspectRatio
- Defined in:
- lib/phlex_ui/aspect_ratio.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(aspect_ratio: "16/9", **attrs) ⇒ AspectRatio
constructor
A new instance of AspectRatio.
- #view_template(&block) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(aspect_ratio: "16/9", **attrs) ⇒ AspectRatio
Returns a new instance of AspectRatio.
5 6 7 8 9 10 |
# File 'lib/phlex_ui/aspect_ratio.rb', line 5 def initialize(aspect_ratio: "16/9", **attrs) raise "aspect_ratio must be in the format of a string with a slash in the middle (eg. '16/9', '1/1')" unless aspect_ratio.is_a?(String) && aspect_ratio.include?("/") @aspect_ratio = aspect_ratio super(**attrs) end |
Instance Method Details
#view_template(&block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/phlex_ui/aspect_ratio.rb', line 12 def view_template(&block) div( class: "relative w-full", style: "padding-bottom: #{padding_bottom}%;" ) do div(**attrs, &block) end end |