Class: Coradoc::Element::Inline::Image
- Inherits:
-
Object
- Object
- Coradoc::Element::Inline::Image
- Defined in:
- lib/coradoc/element/inline/image.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, id, src, options = ()) ⇒ Image
constructor
A new instance of Image.
- #to_adoc ⇒ Object
Constructor Details
#initialize(title, id, src, options = ()) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 12 13 14 |
# File 'lib/coradoc/element/inline/image.rb', line 7 def initialize(title, id, src, = ()) @title = title @id = id @anchor = @id.nil? ? nil : Inline::Anchor.new(@id) @src = src @attributes = .fetch(:attributes, []) @title = .fetch(:title, nil) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/coradoc/element/inline/image.rb', line 6 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/coradoc/element/inline/image.rb', line 6 def id @id end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
6 7 8 |
# File 'lib/coradoc/element/inline/image.rb', line 6 def src @src end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/coradoc/element/inline/image.rb', line 6 def title @title end |
Instance Method Details
#to_adoc ⇒ Object
16 17 18 19 20 21 |
# File 'lib/coradoc/element/inline/image.rb', line 16 def to_adoc anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n" title = ".#{@title}\n" unless @title.to_s.empty? attrs = @attributes.empty? ? "\[\]" : @attributes.to_adoc [anchor, title, "image::", @src, attrs].join("") end |