Class: Coradoc::Element::Inline::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/element/inline/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Link

Returns a new instance of Link.



7
8
9
10
11
# File 'lib/coradoc/element/inline/link.rb', line 7

def initialize(options = {})
  @path = options.fetch(:path,nil)
  @title = options.fetch(:title, nil)
  @name = options.fetch(:name,nil)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/coradoc/element/inline/link.rb', line 5

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/coradoc/element/inline/link.rb', line 5

def path
  @path
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/coradoc/element/inline/link.rb', line 5

def title
  @title
end

Instance Method Details

#to_adocObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/coradoc/element/inline/link.rb', line 13

def to_adoc
  link = @path.to_s =~ URI::DEFAULT_PARSER.make_regexp ? @path : "link:#{@path}"
  if @name.to_s.empty?
    link << "[#{@title}]"
  else
    link << "[#{@name}]"
  end
  link.prepend(' ')
  link
end