Sha256: 67ac6b8cda4a15332a3ab672d9e36df4c288e07730b9a43cdced01e265e84315
Contents?: true
Size: 908 Bytes
Versions: 12
Compression:
Stored size: 908 Bytes
Contents
module Govspeak class ImagePresenter attr_reader :image def initialize(image) @image = image end def url image.respond_to?(:url) ? image.url : image[:url] end def alt_text image.respond_to?(:alt_text) ? image.alt_text : image[:alt_text] end def caption (image.respond_to?(:caption) ? image.caption : image[:caption]).to_s.strip.presence end def credit (image.respond_to?(:credit) ? image.credit : image[:credit]).to_s.strip.presence end def id nil end def figcaption? caption.present? || credit.present? end def figcaption_html lines = [] lines << "<figcaption>" lines << %(<p>#{caption}</p>) if caption.present? lines << %(<p>#{I18n.t('govspeak.image.figure.credit', credit:)}</p>) if credit.present? lines << "</figcaption>" lines.join end end end
Version data entries
12 entries across 12 versions & 1 rubygems