Class: Coradoc::Element::Inline::Link
- Defined in:
- lib/coradoc/element/inline/link.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#right_constrain ⇒ Object
Returns the value of attribute right_constrain.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Link
constructor
A new instance of Link.
- #to_adoc ⇒ Object
Methods inherited from Base
access_children, #children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(options = {}) ⇒ Link
Returns a new instance of Link.
11 12 13 14 15 16 |
# File 'lib/coradoc/element/inline/link.rb', line 11 def initialize( = {}) @path = .fetch(:path, nil) @title = .fetch(:title, nil) @name = .fetch(:name, nil) @right_constrain = .fetch(:right_constrain, false) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/coradoc/element/inline/link.rb', line 7 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/coradoc/element/inline/link.rb', line 7 def path @path end |
#right_constrain ⇒ Object
Returns the value of attribute right_constrain.
7 8 9 |
# File 'lib/coradoc/element/inline/link.rb', line 7 def right_constrain @right_constrain end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/coradoc/element/inline/link.rb', line 7 def title @title end |
Instance Method Details
#to_adoc ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/coradoc/element/inline/link.rb', line 18 def to_adoc link = @path unless @path.to_s&.match?(URI::DEFAULT_PARSER.make_regexp) link = "link:#{link}" end name_empty = @name.to_s.empty? title_empty = @title.to_s.empty? valid_empty_name_link = link.start_with?(%r{https?://}) link << if name_empty && !title_empty "[#{@title}]" elsif !name_empty "[#{@name}]" elsif valid_empty_name_link && !right_constrain "" else "[]" end link end |