class QboButtons::Builder

Attributes

color[RW]
options[RW]
size[RW]
type[RW]

Public Class Methods

new(size:, color:, type:, options: false) click to toggle source
# File lib/qbo_buttons.rb, line 9
def initialize(size:, color:, type:, options: false)
  @size = size
  @color = color
  @type = type
  @options = options || {}
end

Public Instance Methods

display() click to toggle source
# File lib/qbo_buttons.rb, line 22
def display
  view_context.image_tag(filename, options)
end
filename() click to toggle source
# File lib/qbo_buttons.rb, line 16
def filename
  kind = type == :connect ? 'C2QB' : 'Sign_in' 
  filename = "#{kind}_#{color}_btn_#{size}.svg"
  filename
end
render(href) click to toggle source
# File lib/qbo_buttons.rb, line 26
def render(href)
  popup_params = %{'location=1,width=800,height=650,left=' + ((screen.width - 800) / 2) + ',top=' + ((screen.height - 650) / 2)}
  popup = %{window.open('#{href}', 'QboButtons', #{popup_params});}
  view_context.link_to('javascript: false;', onclick: "#{popup}") do
    display
  end
end

Private Instance Methods

view_context() click to toggle source
# File lib/qbo_buttons.rb, line 36
def view_context
  @view_context ||= ActionView::Base.new
end