Class: Swordfish::Node::Image
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#original_name ⇒ Object
Returns the value of attribute original_name.
-
#path ⇒ Object
Returns the value of attribute path.
Attributes inherited from Base
Instance Method Summary collapse
-
#append(node) ⇒ Object
Override Base append because an image node should never have children.
- #to_html ⇒ Object
Methods inherited from Base
#clear_children, #find_nodes_by_type, #inform!, #initialize, #replace, #replace_with, #stylize, #wrap_children
Constructor Details
This class inherits a constructor from Swordfish::Node::Base
Instance Attribute Details
#caption ⇒ Object
Returns the value of attribute caption.
16 17 18 |
# File 'lib/swordfish/nodes/image.rb', line 16 def @caption end |
#original_name ⇒ Object
Returns the value of attribute original_name.
13 14 15 |
# File 'lib/swordfish/nodes/image.rb', line 13 def original_name @original_name end |
#path ⇒ Object
Returns the value of attribute path.
15 16 17 |
# File 'lib/swordfish/nodes/image.rb', line 15 def path @path end |
Instance Method Details
#append(node) ⇒ Object
Override Base append because an image node should never have children
19 20 21 |
# File 'lib/swordfish/nodes/image.rb', line 19 def append(node) raise BadContentError end |
#to_html ⇒ Object
23 24 25 26 27 |
# File 'lib/swordfish/nodes/image.rb', line 23 def to_html @caption ||= "" src = URI::escape(@path ? @path : @original_name) "<img src=\"#{src}\" alt=\"#{CGI::escapeHTML(@caption)}\" title=\"#{CGI::escapeHTML(@caption)}\" />" end |