Class: Card::Chunk::Abstract
Instance Attribute Summary collapse
-
#process_chunk ⇒ Object
readonly
Returns the value of attribute process_chunk.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
- .context_ok?(content, chunk_start) ⇒ Boolean
- .full_match(content, prefix = nil) ⇒ Object
- .full_re(prefix) ⇒ Object
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #card ⇒ Object
- #format ⇒ Object
-
#initialize(match, content) ⇒ Abstract
constructor
A new instance of Abstract.
- #inspect ⇒ Object
- #interpret(match_string, content, params) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(match, content) ⇒ Abstract
Returns a new instance of Abstract.
70 71 72 73 74 75 76 |
# File 'lib/card/chunk.rb', line 70 def initialize match, content @text = match[0] @processed = nil @content = content interpret match, content self end |
Instance Attribute Details
#process_chunk ⇒ Object (readonly)
Returns the value of attribute process_chunk.
53 54 55 |
# File 'lib/card/chunk.rb', line 53 def process_chunk @process_chunk end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
53 54 55 |
# File 'lib/card/chunk.rb', line 53 def text @text end |
Class Method Details
.context_ok?(content, chunk_start) ⇒ Boolean
65 66 67 |
# File 'lib/card/chunk.rb', line 65 def context_ok? content, chunk_start true end |
.full_match(content, prefix = nil) ⇒ Object
56 57 58 59 |
# File 'lib/card/chunk.rb', line 56 def full_match content, prefix=nil # warn "attempting full match on #{content}. class = #{self}" content.match full_re( prefix ) end |
.full_re(prefix) ⇒ Object
61 62 63 |
# File 'lib/card/chunk.rb', line 61 def full_re prefix config[:full_re] end |
Instance Method Details
#as_json(options = {}) ⇒ Object
98 99 100 |
# File 'lib/card/chunk.rb', line 98 def as_json(={}) @process_chunk || @processed|| "not rendered #{self.class}, #{card and card.name}" end |
#card ⇒ Object
86 87 88 |
# File 'lib/card/chunk.rb', line 86 def card @content.card end |
#format ⇒ Object
82 83 84 |
# File 'lib/card/chunk.rb', line 82 def format @content.format end |
#inspect ⇒ Object
94 95 96 |
# File 'lib/card/chunk.rb', line 94 def inspect "<##{self.class}##{to_s}>" end |
#interpret(match_string, content, params) ⇒ Object
78 79 80 |
# File 'lib/card/chunk.rb', line 78 def interpret match_string, content, params Rails.logger.info "no #interpret method found for chunk class: #{self.class}" end |
#to_s ⇒ Object
90 91 92 |
# File 'lib/card/chunk.rb', line 90 def to_s @process_chunk || @processed || @text end |