Sha256: 4f0ed140fb265e4c6c6c493b6006758c473a5bef04f9c45fff30d8661c9d2fe5

Contents?: true

Size: 1013 Bytes

Versions: 14

Compression:

Stored size: 1013 Bytes

Contents

require_relative 'mixins/event'
require_relative 'mixins/tooltips'

module Voom
  module Presenters
    module DSL
      module Components
        class Image < EventBase
          include Mixins::Tooltips

          attr_accessor :image, :height, :width, :position, :selected, :url

          def initialize(**attribs_, &block)
            super(type: :image, context: context,
                  **attribs_, &block)
            @image = attribs.delete(:image)
            @height = attribs.delete(:height)
            @width = attribs.delete(:width)
            @position = Array(attribs.delete(:position)).compact
            @selected = attribs.delete(:selected)
            @url = build_url
            expand!
          end
          
          private
          def build_url
            return nil unless image
            return image if image.start_with?('/') || @image.start_with?('http')
            @parent.router.url(render: image, context: {})
          end

        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
voom-presenters-0.1.13 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.12 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.11 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.10 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.9 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.8 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.7 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.6 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.5 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.4 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.3 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.2 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.1 lib/voom/presenters/dsl/components/image.rb
voom-presenters-0.1.0 lib/voom/presenters/dsl/components/image.rb