Class: Card::Content::Parser
- Inherits:
-
Object
- Object
- Card::Content::Parser
- Defined in:
- lib/card/content/parser.rb
Overview
The Content::Parser breaks content strings into an Array of “chunks”, each of which may be an instance of a Chunk class or a simple String.
Instance Method Summary collapse
-
#initialize(chunk_list, content_object) ⇒ Parser
constructor
to be used in parsing.
-
#parse(content) ⇒ Array
break content string into an array of chunk objects and strings.
Constructor Details
#initialize(chunk_list, content_object) ⇒ Parser
to be used in parsing
10 11 12 13 |
# File 'lib/card/content/parser.rb', line 10 def initialize chunk_list, content_object @content_object = content_object @chunk_list = chunk_list end |
Instance Method Details
#parse(content) ⇒ Array
break content string into an array of chunk objects and strings
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/card/content/parser.rb', line 18 def parse content @content = content @chunks = [] return @chunks unless content.is_a? String @position = @last_position = 0 @interval_string = "" parse_chunks @chunks end |