Class: RenderAsMarkdown::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/render-as-markdown/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alt_text, url, title = nil) ⇒ Image

Returns a new instance of Image.



6
7
8
# File 'lib/render-as-markdown/image.rb', line 6

def initialize alt_text, url, title=nil
  @alt_text, @url, @title = alt_text.to_s, url.to_s, title.to_s
end

Instance Attribute Details

#alt_textObject

Returns the value of attribute alt_text.



4
5
6
# File 'lib/render-as-markdown/image.rb', line 4

def alt_text
  @alt_text
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/render-as-markdown/image.rb', line 4

def title
  @title
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/render-as-markdown/image.rb', line 4

def url
  @url
end

Instance Method Details

#renderObject Also known as: to_s



10
11
12
13
# File 'lib/render-as-markdown/image.rb', line 10

def render
  title = " \"#{@title}\"" unless @title.empty?
  "![#{@alt_text}](#{@url}#{title})"
end