Class: Coradoc::Element::Image::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/element/image/core.rb

Direct Known Subclasses

BlockImage, InlineImage

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = ())
  @title = title
  @id = id
  @anchor = @id.nil? ? nil : Coradoc::Element::Inline::Anchor.new(@id)
  @src = src
  @attributes = options.fetch(:attributes, [])
  @title = options.fetch(:title, nil)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/coradoc/element/image/core.rb', line 5

def attributes
  @attributes
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/coradoc/element/image/core.rb', line 5

def id
  @id
end

#srcObject (readonly)

Returns the value of attribute src.



5
6
7
# File 'lib/coradoc/element/image/core.rb', line 5

def src
  @src
end

#titleObject (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_adocObject



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