Class: CafeCar::StringPresenter
- Inherits:
-
Object
- Object
- CafeCar::StringPresenter
- Defined in:
- app/presenters/cafe_car/string_presenter.rb
Instance Method Summary collapse
Instance Method Details
#title ⇒ Object
3 |
# File 'app/presenters/cafe_car/string_presenter.rb', line 3 def title = to_s |
#to_s ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/presenters/cafe_car/string_presenter.rb', line 5 def to_s length = @options[:truncate] txt = object txt = @template.truncate(txt, length:) if length case object when %r{^https?://.+\.(png|jpe?g|svg)$} @template.image_tag object, style: "width: 1em" when %r{^https?://} link_to(txt, object, target: "_blank", rel: "noopener") else txt end end |