Class: HS::Image

Inherits:
Element show all
Defined in:
lib/hs/elements/image.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#children, #class_name, #style

Instance Method Summary collapse

Methods inherited from Element

#initialize, #preview

Methods included from ElementPreview

#element_preview, #text_preview

Constructor Details

This class inherits a constructor from HS::Element

Instance Attribute Details

#srcObject



15
16
17
18
19
20
# File 'lib/hs/elements/image.rb', line 15

def src
  return unless @src
  return @src if @src =~ %r{^http(s)?://}
  return @src if @src.start_with?('/')
  "/images/#{@src}"
end

Instance Method Details

#paramsObject



11
12
13
# File 'lib/hs/elements/image.rb', line 11

def params
  super.merge(src: src)
end

#tag_nameObject



7
8
9
# File 'lib/hs/elements/image.rb', line 7

def tag_name
  'img'
end