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

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

Constructor Details

#initialize(href, args = nil) ⇒ CrossReference



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

def initialize(href, args = nil)
  @href = href
  @args = args
  @args = nil if @args == ""
  @args = [@args] unless @args.is_a?(Array) || @args == nil
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



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

def args
  @args
end

#hrefObject

Returns the value of attribute href.



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

def href
  @href
end

Instance Method Details

#to_adocObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/coradoc/element/inline/cross_reference.rb', line 16

def to_adoc
  if @args
    args = @args.map do |a|
      Coradoc::Generator.gen_adoc(a)
    end.join(",")
    if args.empty?
      return "<<#{@href}>>"
    else
      return "<<#{@href},#{args}>>"
    end
  end
  "<<#{@href}>>"
end