Class: Poppins::InlineLink
- Inherits:
-
Object
- Object
- Poppins::InlineLink
- Defined in:
- lib/poppins/inline_link.rb
Instance Attribute Summary collapse
-
#link_text ⇒ Object
Returns the value of attribute link_text.
-
#reference_label ⇒ Object
Returns the value of attribute reference_label.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #as_found_in_text ⇒ Object
-
#initialize(url, link_text) ⇒ InlineLink
constructor
A new instance of InlineLink.
-
#regex ⇒ Object
Returns a regular expression that can be used to find examples of this link in a sample text.
- #to_s ⇒ Object
Constructor Details
#initialize(url, link_text) ⇒ InlineLink
Returns a new instance of InlineLink.
9 10 11 12 |
# File 'lib/poppins/inline_link.rb', line 9 def initialize(url, link_text) @url = url @link_text = link_text end |
Instance Attribute Details
#link_text ⇒ Object
Returns the value of attribute link_text.
7 8 9 |
# File 'lib/poppins/inline_link.rb', line 7 def link_text @link_text end |
#reference_label ⇒ Object
Returns the value of attribute reference_label.
7 8 9 |
# File 'lib/poppins/inline_link.rb', line 7 def reference_label @reference_label end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/poppins/inline_link.rb', line 6 def url @url end |
Class Method Details
.inline_regex ⇒ Object
14 15 16 |
# File 'lib/poppins/inline_link.rb', line 14 def self.inline_regex @inline_regex end |
Instance Method Details
#as_found_in_text ⇒ Object
18 19 20 |
# File 'lib/poppins/inline_link.rb', line 18 def as_found_in_text "[#{@link_text}](#{@url})" end |
#regex ⇒ Object
Returns a regular expression that can be used to find examples of this link in a sample text.
29 30 31 |
# File 'lib/poppins/inline_link.rb', line 29 def regex /\[([^\]]+)\]\((#{Regexp.quote(@url)})\)/ end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/poppins/inline_link.rb', line 22 def to_s as_found_in_text end |