Class: RenderAsMarkdown::Image
- Inherits:
-
Object
- Object
- RenderAsMarkdown::Image
- Defined in:
- lib/render-as-markdown/image.rb
Instance Attribute Summary collapse
-
#alt_text ⇒ Object
Returns the value of attribute alt_text.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(alt_text, url, title = nil) ⇒ Image
constructor
A new instance of Image.
- #render ⇒ Object (also: #to_s)
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_text ⇒ Object
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 |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/render-as-markdown/image.rb', line 4 def title @title end |
#url ⇒ Object
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
#render ⇒ Object 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 |