Class: Coradoc::Element::Image::Core
- Inherits:
-
Object
- Object
- Coradoc::Element::Image::Core
- Defined in:
- lib/coradoc/element/image/core.rb
Direct Known Subclasses
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 = ()) ⇒ Core
constructor
A new instance of Core.
- #to_adoc ⇒ Object
Constructor Details
#initialize(title, id, src, options = ()) ⇒ Core
Returns a new instance of Core.
6 7 8 9 10 11 12 13 |
# File 'lib/coradoc/element/image/core.rb', line 6 def initialize(title, id, src, = ()) @title = title @id = id @anchor = @id.nil? ? nil : Coradoc::Element::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.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def id @id end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def src @src end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def title @title end |
Instance Method Details
#to_adoc ⇒ Object
15 16 17 18 19 20 |
# File 'lib/coradoc/element/image/core.rb', line 15 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", @colons, @src, attrs].join("") end |