123456789_123456789_123456789_123456789_123456789_

Class: ActionText::Attachables::RemoteImage

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Inherits: Object
Defined in: actiontext/lib/action_text/attachables/remote_image.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(attributes = {}) ⇒ RemoteImage

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 32

def initialize(attributes = {})
  @url = attributes[:url]
  @content_type = attributes[:content_type]
  @width = attributes[:width]
  @height = attributes[:height]
end

Class Method Details

.attributes_from_node(node) (private)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 22

def attributes_from_node(node)
  { url: node["url"],
    content_type: node["content-type"],
    width: node["width"],
    height: node["height"] }
end

.content_type_is_image?(content_type) ⇒ Boolean (private)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 18

def content_type_is_image?(content_type)
  content_type.to_s.match?(/^image(\/.+|$)/)
end

.from_node(node)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 11

def from_node(node)
  if node["url"] && content_type_is_image?(node["content-type"])
    new(attributes_from_node(node))
  end
end

Instance Attribute Details

#content_type (readonly)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 30

attr_reader :url, :content_type, :width, :height

#height (readonly)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 30

attr_reader :url, :content_type, :width, :height

#url (readonly)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 30

attr_reader :url, :content_type, :width, :height

#width (readonly)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 30

attr_reader :url, :content_type, :width, :height

Instance Method Details

#attachable_plain_text_representation(caption)

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 39

def attachable_plain_text_representation(caption)
  "[#{caption || "Image"}]"
end

#to_partial_path

[ GitHub ]

  
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 43

def to_partial_path
  "action_text/attachables/remote_image"
end