Class: PhrasingBackgroundImageWidget

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/widgets/phrasing_background_image_widget.rb

Constant Summary collapse

HTML_CLASS =
'phrasable-background-image'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phrasing_image, view_context, wrapped_html, options = {}) ⇒ PhrasingBackgroundImageWidget

Returns a new instance of PhrasingBackgroundImageWidget.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/widgets/phrasing_background_image_widget.rb', line 9

def initialize(phrasing_image, view_context, wrapped_html, options = {})
  super(phrasing_image)
  @view_context = view_context
  @wrapped_html = wrapped_html
  @options = options
  @default_image = @options.delete(:default_image)
  @options[:style] = "background-image: url(#{image_url})"
  @tag = @options.delete(:tag)

  return unless view_context.can_edit_phrases?

  add_phrasable_image_class
end

Instance Attribute Details

#default_imageObject

Returns the value of attribute default_image.



7
8
9
# File 'app/widgets/phrasing_background_image_widget.rb', line 7

def default_image
  @default_image
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'app/widgets/phrasing_background_image_widget.rb', line 7

def options
  @options
end

#wrapped_htmlObject

Returns the value of attribute wrapped_html.



7
8
9
# File 'app/widgets/phrasing_background_image_widget.rb', line 7

def wrapped_html
  @wrapped_html
end

Instance Method Details

#tagObject



23
24
25
# File 'app/widgets/phrasing_background_image_widget.rb', line 23

def tag
  @tag || :div
end