Class: EmphasisParser
- Inherits:
-
Object
- Object
- EmphasisParser
- Includes:
- Assert
- Defined in:
- lib/ribit/contentparser.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create_emphasis_container ⇒ Object
-
#initialize(tag) ⇒ EmphasisParser
constructor
A new instance of EmphasisParser.
- #parse(text, contentDoc) ⇒ Object
Methods included from Assert
assert, #assert, assert_nil, #assert_nil, #assert_not_nil, assert_not_nil, raise_exception
Constructor Details
#initialize(tag) ⇒ EmphasisParser
Returns a new instance of EmphasisParser.
191 192 193 194 |
# File 'lib/ribit/contentparser.rb', line 191 def initialize( tag ) assert_not_nil( tag ) @tag = tag end |
Instance Method Details
#create_emphasis_container ⇒ Object
197 198 199 |
# File 'lib/ribit/contentparser.rb', line 197 def create_emphasis_container() raise 'implement this' end |
#parse(text, contentDoc) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/ribit/contentparser.rb', line 202 def parse( text, contentDoc ) #puts "em parser handling text = " + text newContainers = Array.new # @tag starts and ends subStrs = text.split( @tag ) emOpen = false subStrs.each do |sub| if ( !emOpen ) newContainers.push( TextContainer.new( sub ) ) unless sub.size() == 0 emOpen = true else # element is open emContainer = create_emphasis_container() emContainer << sub newContainers.push( emContainer ) emOpen = false end end str = '' newContainers.each do |n| str << n.to_s end #puts "newContainer contains = " + str return newContainers end |