class Card::Content::Chunk::Abstract

Attributes

process_chunk[R]
text[R]

Public Class Methods

context_ok?(_content, _chunk_start) click to toggle source
# File lib/card/content/chunk/abstract.rb, line 24
def context_ok? _content, _chunk_start
  true
end
full_match(content, prefix=nil) click to toggle source

if the prefix regex matched check that chunk against the full regex

# File lib/card/content/chunk/abstract.rb, line 16
def full_match content, prefix=nil
  content.match full_re(prefix)
end
full_re(_prefix) click to toggle source
# File lib/card/content/chunk/abstract.rb, line 20
def full_re _prefix
  config[:full_re]
end
new(match, content) click to toggle source
# File lib/card/content/chunk/abstract.rb, line 33
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

as_json(_options={}) click to toggle source
# File lib/card/content/chunk/abstract.rb, line 81
def as_json _options={}
  burn_read || @process_chunk || @processed ||
    "not rendered #{self.class}, #{card&.name}"
end
burn_after_reading(text) click to toggle source

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

# File lib/card/content/chunk/abstract.rb, line 73
def burn_after_reading text
  @burn_read = text
end
burn_read() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 62
def burn_read
  return unless @burn_read

  tmp = @burn_read
  @burn_read = nil
  tmp
end
card() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 50
def card
  @content.card
end
format() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 46
def format
  @content.format
end
inspect() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 77
def inspect
  "<##{self.class}##{self}>"
end
interpret(_match_string, _content) click to toggle source
# File lib/card/content/chunk/abstract.rb, line 41
def interpret _match_string, _content
  Rails.logger.info "no #interpret method found for chunk class: " \
                    "#{self.class}"
end
reference_code() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 29
def reference_code
  "I"
end
result() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 58
def result
  burn_read || @process_chunk || @processed || @text
end
to_s() click to toggle source
# File lib/card/content/chunk/abstract.rb, line 54
def to_s
  result
end