Class: Card::Content::Chunk::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/card/content/chunk.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match, content) ⇒ Abstract

Returns a new instance of Abstract.



82
83
84
85
86
87
88
# File 'lib/card/content/chunk.rb', line 82

def initialize match, content
  @text = match[0]
  @processed = nil
  @content = content
  interpret match, content
  self
end

Instance Attribute Details

#process_chunkObject (readonly)

Returns the value of attribute process_chunk.



61
62
63
# File 'lib/card/content/chunk.rb', line 61

def process_chunk
  @process_chunk
end

#textObject (readonly)

Returns the value of attribute text.



61
62
63
# File 'lib/card/content/chunk.rb', line 61

def text
  @text
end

Class Method Details

.context_ok?(_content, _chunk_start) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/card/content/chunk.rb', line 73

def context_ok? _content, _chunk_start
  true
end

.full_match(content, prefix = nil) ⇒ Object

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



65
66
67
# File 'lib/card/content/chunk.rb', line 65

def full_match content, prefix=nil
  content.match full_re(prefix)
end

.full_re(_prefix) ⇒ Object



69
70
71
# File 'lib/card/content/chunk.rb', line 69

def full_re _prefix
  config[:full_re]
end

Instance Method Details

#as_json(_options = {}) ⇒ Object



111
112
113
114
# File 'lib/card/content/chunk.rb', line 111

def as_json _options={}
  @process_chunk || @processed ||
    "not rendered #{self.class}, #{card && card.name}"
end

#cardObject



99
100
101
# File 'lib/card/content/chunk.rb', line 99

def card
  @content.card
end

#formatObject



95
96
97
# File 'lib/card/content/chunk.rb', line 95

def format
  @content.format
end

#inspectObject



107
108
109
# File 'lib/card/content/chunk.rb', line 107

def inspect
  "<##{self.class}##{self}>"
end

#interpret(_match_string, _content, _params) ⇒ Object



90
91
92
93
# File 'lib/card/content/chunk.rb', line 90

def interpret _match_string, _content, _params
  Rails.logger.info 'no #interpret method found for chunk class: ' \
                    "#{self.class}"
end

#reference_codeObject



78
79
80
# File 'lib/card/content/chunk.rb', line 78

def reference_code
  'I'
end

#to_sObject



103
104
105
# File 'lib/card/content/chunk.rb', line 103

def to_s
  @process_chunk || @processed || @text
end