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 valud 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.



50
51
52
53
54
55
56
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 50

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



70
71
72
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 70

def cropped
  @attributes[:cropped]
end

#heightObject



66
67
68
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 66

def height
  @attributes[:height]
end

#present?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 74

def present?
  self.source.present?
end

#sourceObject



58
59
60
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 58

def source
  @attributes[:source]
end

#to_sObject



78
79
80
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 78

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

#widthObject



62
63
64
# File 'lib/locomotive/steam/liquid/drops/section_content_proxy.rb', line 62

def width
  @attributes[:width]
end