Class: Poppins::InlineLink

Inherits:
Object
  • Object
show all
Defined in:
lib/poppins/inline_link.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

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_labelObject

Returns the value of attribute reference_label.



7
8
9
# File 'lib/poppins/inline_link.rb', line 7

def reference_label
  @reference_label
end

#urlObject (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_regexObject



14
15
16
# File 'lib/poppins/inline_link.rb', line 14

def self.inline_regex
  @inline_regex
end

Instance Method Details

#as_found_in_textObject



18
19
20
# File 'lib/poppins/inline_link.rb', line 18

def as_found_in_text
  "[#{@link_text}](#{@url})"
end

#regexObject

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_sObject



22
23
24
# File 'lib/poppins/inline_link.rb', line 22

def to_s
  as_found_in_text
end