class Card::Content::Chunk::Uri
Constants
- REJECTED_PREFIX_RE
- SCHEMES
Attributes
link_text[R]
uri[R]
Public Class Methods
context_ok?(content, chunk_start)
click to toggle source
# File lib/card/content/chunk/uri.rb, line 51 def context_ok? content, chunk_start preceding_string = content[chunk_start - 2..chunk_start - 1] preceding_string !~ /(?:#{REJECTED_PREFIX_RE})$/ end
full_match(content, prefix)
click to toggle source
Calls superclass method
# File lib/card/content/chunk/uri.rb, line 40 def full_match content, prefix prepend_str = if prefix[-1, 1] != ":" && config[:prepend_str] config[:prepend_str] else "" end content = prepend_str + content match = super content, prefix [match, prepend_str.length] end
Public Instance Methods
interpret(match, _content)
click to toggle source
# File lib/card/content/chunk/uri.rb, line 57 def interpret match, _content chunk = match[0] last_char = chunk[-1, 1] chunk.gsub!(/(?: )+/, "") @trailing_punctuation = if %w[, . ) ! ? :].member?(last_char) @text.chop! chunk.chop! last_char end chunk.sub!(/\.$/, "") @link_text = chunk @uri = ::URI.parse(chunk) @process_chunk = process_uri_chunk rescue ::URI::Error => e # warn "rescue parse #{chunk_class}: # '#{m}' #{e.inspect} #{e.backtrace*"\n"}" Rails.logger.warn "rescue parse #{self.class}: #{e.inspect}" end
Private Instance Methods
process_text()
click to toggle source
# File lib/card/content/chunk/uri.rb, line 81 def process_text @link_text end
process_uri_chunk()
click to toggle source
# File lib/card/content/chunk/uri.rb, line 85 def process_uri_chunk link = format.link_to_resource @link_text, process_text "#{link}#{@trailing_punctuation}" end