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

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

Direct Known Subclasses

EscapedLiteral, Reference, URI, ViewStub

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match, content) ⇒ Abstract

Returns a new instance of Abstract.



101
102
103
104
105
106
107
# File 'lib/card/content/chunk.rb', line 101

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.



80
81
82
# File 'lib/card/content/chunk.rb', line 80

def process_chunk
  @process_chunk
end

#textObject (readonly)

Returns the value of attribute text.



80
81
82
# File 'lib/card/content/chunk.rb', line 80

def text
  @text
end

Class Method Details

.context_ok?(_content, _chunk_start) ⇒ Boolean

Returns:

  • (Boolean)


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

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



84
85
86
# File 'lib/card/content/chunk.rb', line 84

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

.full_re(_prefix) ⇒ Object



88
89
90
# File 'lib/card/content/chunk.rb', line 88

def full_re _prefix
  config[:full_re]
end

Instance Method Details

#as_json(_options = {}) ⇒ Object



134
135
136
137
# File 'lib/card/content/chunk.rb', line 134

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

#cardObject



118
119
120
# File 'lib/card/content/chunk.rb', line 118

def card
  @content.card
end

#formatObject



114
115
116
# File 'lib/card/content/chunk.rb', line 114

def format
  @content.format
end

#inspectObject



130
131
132
# File 'lib/card/content/chunk.rb', line 130

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

#interpret(_match_string, _content, _params) ⇒ Object



109
110
111
112
# File 'lib/card/content/chunk.rb', line 109

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

#reference_codeObject



97
98
99
# File 'lib/card/content/chunk.rb', line 97

def reference_code
  "I"
end

#resultObject



126
127
128
# File 'lib/card/content/chunk.rb', line 126

def result
  @process_chunk || @processed || @text
end

#to_sObject



122
123
124
# File 'lib/card/content/chunk.rb', line 122

def to_s
  result
end