Class: Card::Chunk::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/card/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.



79
80
81
82
83
84
85
# File 'lib/card/chunk.rb', line 79

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.



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

def process_chunk
  @process_chunk
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Class Method Details

.context_ok?(content, chunk_start) ⇒ Boolean

Returns:

  • (Boolean)


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

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
68
# File 'lib/card/chunk.rb', line 65

def full_match content, prefix=nil
  #        warn "attempting full match on #{content}.  class = #{self}"
  content.match full_re( prefix )
end

.full_re(prefix) ⇒ Object



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

def full_re prefix
  config[:full_re]
end

Instance Method Details

#as_json(options = {}) ⇒ Object



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

def as_json(options={})
  @process_chunk || @processed|| "not rendered #{self.class}, #{card and card.name}"
end

#cardObject



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

def card
  @content.card
end

#formatObject



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

def format
  @content.format
end

#inspectObject



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

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

#interpret(match_string, content, params) ⇒ Object



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

def interpret match_string, content, params
  Rails.logger.info "no #interpret method found for chunk class: #{self.class}"
end

#to_sObject



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

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