Sha256: b9450097d346944b7d76b0efa23bf4e1f2148545619201a43f0dc2103879dc9a

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

module Yashare
  class Widget
    def initialize(view, opts={})
      @view = view

      @services = opts.fetch(:services, ['vkontakte', 'facebook', 'twitter', 'lj'])
      @image    = opts.fetch(:image,    nil)
      @type     = opts.fetch(:type,     'button')
      @lang     = opts.fetch(:lang,     'ru')
    end

    def to_s
      attrs = {
        class: 'yashare-auto-init',
        data: {
          yashareL10n: lang,
          yashareType: type,
          yashareQuickServices: services.join(',')
        }
      }

      if type == 'small'
        attrs[:data][:yashareTheme] = 'counter'
      end

      if image.present?
        attrs[:data][:yashareImage] = image
      end

      view.content_tag(:div, nil, attrs)
    end

    private

    attr_reader :view, :type, :services, :image, :lang
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yashare-0.1 lib/yashare/widget.rb