Class: SlideHero::Image
- Inherits:
-
Object
- Object
- SlideHero::Image
- Defined in:
- lib/slide_hero/image.rb
Instance Attribute Summary collapse
-
#alt_text ⇒ Object
readonly
Returns the value of attribute alt_text.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #compile ⇒ Object
- #height_attribute ⇒ Object
-
#initialize(location, alt_text = "", width: nil, height: nil) ⇒ Image
constructor
A new instance of Image.
- #width_attribute ⇒ Object
Constructor Details
#initialize(location, alt_text = "", width: nil, height: nil) ⇒ Image
Returns a new instance of Image.
4 5 6 7 8 9 |
# File 'lib/slide_hero/image.rb', line 4 def initialize(location, alt_text="", width:nil, height:nil) @location = location @alt_text = alt_text @width = width @height = height end |
Instance Attribute Details
#alt_text ⇒ Object (readonly)
Returns the value of attribute alt_text.
3 4 5 |
# File 'lib/slide_hero/image.rb', line 3 def alt_text @alt_text end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
3 4 5 |
# File 'lib/slide_hero/image.rb', line 3 def height @height end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/slide_hero/image.rb', line 3 def location @location end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
3 4 5 |
# File 'lib/slide_hero/image.rb', line 3 def width @width end |
Instance Method Details
#compile ⇒ Object
11 12 13 |
# File 'lib/slide_hero/image.rb', line 11 def compile %{<img#{width_attribute}#{height_attribute} src="images/#{location}" alt="#{alt_text}">} end |
#height_attribute ⇒ Object
15 16 17 |
# File 'lib/slide_hero/image.rb', line 15 def height_attribute %{ height="#{height}"} if height end |
#width_attribute ⇒ Object
19 20 21 |
# File 'lib/slide_hero/image.rb', line 19 def width_attribute %{ width="#{width}"} if width end |