Class: AdComponent

Inherits:
Component show all
Defined in:
app/components/ad_component.rb

Overview

Ad — standard ad unit sizes following IAB standards.

Usage:

Ad(unit: :leaderboard)
Ad(unit: :medium_rectangle, test: "Ad Placeholder")

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/components/ad_component.rb', line 13

def to_s
  unit_class = unit.to_s.tr("_", " ")

  classes = class_names(
    "ui",
    unit_class,
    { "test" => test },
    "ad"
  )

  opts = { class: classes }
  opts[:data] = { text: test } if test

  tag.div(**opts) { @content }
end