Sha256: e45eefac251a759e3ea93f5a4a9471cb8ad8f8df5959684a3347e56c271404c8

Contents?: true

Size: 447 Bytes

Versions: 1

Compression:

Stored size: 447 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 id
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
govspeak-5.8.0 lib/govspeak/presenters/image_presenter.rb