class Card::Content::Chunk::Abstract
Abstract
class used for all different types of chunks of card content
Attributes
Public Class Methods
Source
# File lib/card/content/chunk/abstract.rb, line 25 def context_ok? _content, _chunk_start true end
Source
# File lib/card/content/chunk/abstract.rb, line 17 def full_match content, prefix=nil content.match full_re(prefix) end
if the prefix regex matched check that chunk against the full regex
Source
# File lib/card/content/chunk/abstract.rb, line 21 def full_re _prefix config[:full_re] end
Source
# File lib/card/content/chunk/abstract.rb, line 34 def initialize match, content match = self.class.full_match(match) if match.is_a? String @text = match[0] @processed = nil @content = content interpret match, content end
Public Instance Methods
Source
# File lib/card/content/chunk/abstract.rb, line 82 def as_json _options={} burn_read || @process_chunk || @processed || "not rendered #{self.class}, #{card&.name}" end
Source
# File lib/card/content/chunk/abstract.rb, line 74 def burn_after_reading text @burn_read = text end
Temporarily overrides the processed nest content for single-use After using the nest’s result (for example via ‘to_s`) the original result is restored
Source
# File lib/card/content/chunk/abstract.rb, line 63 def burn_read return unless @burn_read tmp = @burn_read @burn_read = nil tmp end
Source
# File lib/card/content/chunk/abstract.rb, line 78 def inspect "<##{self.class}##{self}>" end
Source
# File lib/card/content/chunk/abstract.rb, line 42 def interpret _match_string, _content Rails.logger.info "no #interpret method found for chunk class: " \ "#{self.class}" end
Source
# File lib/card/content/chunk/abstract.rb, line 30 def reference_code "I" end
Source
# File lib/card/content/chunk/abstract.rb, line 59 def result burn_read || @process_chunk || @processed || @text end