Class: Ntxt::Ntxt

Inherits:
Object
  • Object
show all
Defined in:
lib/ntxt/ntxt.rb

Overview

Root class that contains the text array that Block objects reference.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Ntxt

Create a new Ntxt object. This requires a String that is the text of the object.

ntxt = Ntxt::Ntxt.new( File.open('n.txt'){ |io| io.read } )


17
18
19
20
# File 'lib/ntxt/ntxt.rb', line 17

def initialize(text)
  @text  = text
  @rootBlock = (Parser.new).parse(self)
end

Instance Attribute Details

#rootBlockObject

The root Block. It will contain all tags in the document and has a Block.start of 0 and a Block.offset of #text.length.



12
13
14
# File 'lib/ntxt/ntxt.rb', line 12

def rootBlock
  @rootBlock
end

#textObject

The raw text file. This is a String.



8
9
10
# File 'lib/ntxt/ntxt.rb', line 8

def text
  @text
end

Instance Method Details

#walkText(print, enter, exit) ⇒ Object

Calls Block#walkText.



23
24
25
# File 'lib/ntxt/ntxt.rb', line 23

def walkText(print, enter, exit)
  @rootBlock.walkText(print, enter, exit)
end