Class: Treat::Workers::Processors::Chunkers::TXT
- Inherits:
-
Object
- Object
- Treat::Workers::Processors::Chunkers::TXT
- Defined in:
- lib/treat/workers/processors/chunkers/txt.rb
Class Method Summary collapse
-
.chunk(entity, options = {}) ⇒ Object
Separates a string into zones on the basis of newlines.
Class Method Details
.chunk(entity, options = {}) ⇒ Object
Separates a string into zones on the basis of newlines.
Options: none.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/treat/workers/processors/chunkers/txt.rb', line 7 def self.chunk(entity, = {}) entity.check_hasnt_children zones = entity.to_s.split("\n") current = entity zones.each do |zone| zone.strip! next if zone == '' c = Treat::Entities::Zone.from_string(zone) if c.type == :title if current.type == :section current = current.parent current = entity << Treat::Entities::Section.new else current = entity << Treat::Entities::Section.new end end current << c end end |