Class: RuBB::Node::Image
- Inherits:
-
RuBB::Node
- Object
- RuBB::Node
- RuBB::Node::Image
- Defined in:
- lib/rubb/node/image.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from RuBB::Node
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Image
constructor
A new instance of Image.
- #to_html ⇒ Object
Methods inherited from RuBB::Node
Constructor Details
#initialize(options = {}) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 |
# File 'lib/rubb/node/image.rb', line 7 def initialize(={}) super() @width = [:width] @height = [:height] end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
5 6 7 |
# File 'lib/rubb/node/image.rb', line 5 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
4 5 6 |
# File 'lib/rubb/node/image.rb', line 4 def width @width end |
Instance Method Details
#to_html ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rubb/node/image.rb', line 13 def to_html if(@width && @height) url = Parser.escape_quotes(@children.map {|c| c ? c.to_html : '' }.join) html = "<img src=\"#{url}\" style=\"width: #{@width}px; height: #{@height}px;\" alt=\"\" />" else url = Parser.escape_quotes(@children.map {|c| c ? c.to_html : '' }.join) html = "<img src=\"#{url}\" alt=\"\" />" end end |