Class: ActionText::Attachables::RemoteImage

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Defined in:
actiontext/lib/action_text/attachables/remote_image.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveModel::Naming

extended, model_name, param_key, plural, route_key, singular, singular_route_key, uncountable?

Constructor Details

#initialize(attributes = {}) ⇒ RemoteImage

Returns a new instance of RemoteImage.



30
31
32
33
34
35
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 30

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

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type



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

def content_type
  @content_type
end

#heightObject (readonly)

Returns the value of attribute height



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

def height
  @height
end

#urlObject (readonly)

Returns the value of attribute url



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

def url
  @url
end

#widthObject (readonly)

Returns the value of attribute width



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

def width
  @width
end

Class Method Details

.from_node(node) ⇒ Object



9
10
11
12
13
# File 'actiontext/lib/action_text/attachables/remote_image.rb', line 9

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

Instance Method Details

#attachable_plain_text_representation(caption) ⇒ Object



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

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

#to_partial_pathObject



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

def to_partial_path
  "action_text/attachables/remote_image"
end