Class: MdInc::TextProcessor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TextProcessor

Returns a new instance of TextProcessor.



9
10
11
# File 'lib/md_inc.rb', line 9

def initialize(options={})
  @options = options
end

Instance Attribute Details

#rootObject

Returns the value of attribute root.



7
8
9
# File 'lib/md_inc.rb', line 7

def root
  @root
end

Instance Method Details

#process(string) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/md_inc.rb', line 13

def process(string)
  context = OpenStruct.new(@options)
  context.root = root
  context.options = @options
  context.extend Commands
  if @options[:modules]
    @options[:modules].each {|m| context.extend m}
  end
  context.process(string)
end

#process_file(path) ⇒ Object



28
29
30
# File 'lib/md_inc.rb', line 28

def process_file(path)
  process(File.read(path))
end

#process_stream(stream) ⇒ Object



24
25
26
# File 'lib/md_inc.rb', line 24

def process_stream(stream)
  process(stream.read)
end