Class: Coradoc::Element::Inline::CrossReference

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

children_accessors, #children_accessors, declare_children, #simplify_block_content, visit, #visit

Constructor Details

#initialize(href, name = nil) ⇒ CrossReference

Returns a new instance of CrossReference.



9
10
11
12
# File 'lib/coradoc/element/inline/cross_reference.rb', line 9

def initialize(href, name = nil)
  @href = href
  @name = name
end

Instance Attribute Details

#hrefObject

Returns the value of attribute href.



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

def href
  @href
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#to_adocObject



14
15
16
17
18
19
20
# File 'lib/coradoc/element/inline/cross_reference.rb', line 14

def to_adoc
  if @name.to_s.empty?
    "<<#{@href}>>"
  else
    "<<#{@href},#{@name}>>"
  end
end