Class: Locomotive::Steam::Liquid::Drops::SectionImagePickerField

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/locomotive/steam/liquid/drops/section_content_proxy.rb

Overview

Drop representing the value of an image picker. It holds extra attributes like: the width, height, format and cropped of the image

Instance Method Summary collapse

Constructor Details

#initialize(url_or_attributes) ⇒ SectionImagePickerField

Returns a new instance of SectionImagePickerField.



89
90
91
92
93
94
95
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 89

def initialize(url_or_attributes)
  if url_or_attributes.is_a?(String) || url_or_attributes.blank?
    @attributes = { source: url_or_attributes }
  else
    @attributes = url_or_attributes.symbolize_keys || {}
  end
end

Instance Method Details

#croppedObject



109
110
111
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 109

def cropped
  @attributes[:cropped]
end

#heightObject



105
106
107
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 105

def height
  @attributes[:height]
end

#present?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 113

def present?
  self.source.present?
end

#sourceObject



97
98
99
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 97

def source
  @attributes[:source]
end

#to_sObject



117
118
119
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 117

def to_s
  self.cropped || self.source || ''
end

#widthObject



101
102
103
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 101

def width
  @attributes[:width]
end