class Sociyal::Widget
Attributes
image[R]
lang[R]
services[R]
type[R]
view[R]
Public Class Methods
new(view, opts = {})
click to toggle source
# File lib/sociyal/widget.rb, line 3 def initialize(view, opts = {}) @view = view @services = opts.fetch(:services, %w(vkontakte facebook twitter lj)) @image = opts.fetch(:image, nil) @type = opts.fetch(:type, 'button') @lang = opts.fetch(:lang, 'ru') end
Public Instance Methods
to_s()
click to toggle source
# File lib/sociyal/widget.rb, line 12 def to_s @html ||= render end
Private Instance Methods
data_attrs()
click to toggle source
# File lib/sociyal/widget.rb, line 22 def data_attrs { yashareQuickServices: Array(services).join(','), yashareL10n: lang, yashareType: type }.tap do |data| data[:yashareTheme] = 'counter' if type.to_s == 'small' data[:yashareImage] = image if image.present? end end
render()
click to toggle source
# File lib/sociyal/widget.rb, line 18 def render view.content_tag(:div, nil, class: 'yashare-auto-init', data: data_attrs) end