Class: Prismic::Fragments::Image::View
- Defined in:
- lib/prismic/fragments/image.rb
Instance Attribute Summary collapse
-
#alt ⇒ Object
Returns the value of attribute alt.
-
#copyright ⇒ Object
Returns the value of attribute copyright.
-
#height ⇒ Object
Returns the value of attribute height.
-
#link_to ⇒ Object
Returns the value of attribute link_to.
-
#url ⇒ Object
Returns the value of attribute url.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #as_html(link_resolver = nil) ⇒ Object
-
#initialize(url, width, height, alt, copyright, link_to) ⇒ View
constructor
A new instance of View.
- #ratio ⇒ Object
Methods inherited from Fragment
Constructor Details
#initialize(url, width, height, alt, copyright, link_to) ⇒ View
Returns a new instance of View
41 42 43 44 45 46 47 48 |
# File 'lib/prismic/fragments/image.rb', line 41 def initialize(url, width, height, alt, copyright, link_to) @url = url @width = width @height = height @alt = alt @copyright = copyright @link_to = link_to end |
Instance Attribute Details
#alt ⇒ Object
Returns the value of attribute alt
39 40 41 |
# File 'lib/prismic/fragments/image.rb', line 39 def alt @alt end |
#copyright ⇒ Object
Returns the value of attribute copyright
39 40 41 |
# File 'lib/prismic/fragments/image.rb', line 39 def copyright @copyright end |
#height ⇒ Object
Returns the value of attribute height
39 40 41 |
# File 'lib/prismic/fragments/image.rb', line 39 def height @height end |
#link_to ⇒ Object
Returns the value of attribute link_to
39 40 41 |
# File 'lib/prismic/fragments/image.rb', line 39 def link_to @link_to end |
#url ⇒ Object
Returns the value of attribute url
39 40 41 |
# File 'lib/prismic/fragments/image.rb', line 39 def url @url end |
#width ⇒ Object
Returns the value of attribute width
39 40 41 |
# File 'lib/prismic/fragments/image.rb', line 39 def width @width end |
Instance Method Details
#as_html(link_resolver = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/prismic/fragments/image.rb', line 54 def as_html(link_resolver=nil) html = [] html << (link_to.nil? ? '' : link_to.start_html(link_resolver)) html << %(<img src="#@url" alt="#@alt" width="#@width" height="#@height" />) html << (link_to.nil? ? '' : link_to.end_html) html.join end |
#ratio ⇒ Object
50 51 52 |
# File 'lib/prismic/fragments/image.rb', line 50 def ratio return @width / @height end |