Class: MdInc::TextProcessor
- Inherits:
-
Object
- Object
- MdInc::TextProcessor
- Defined in:
- lib/md_inc.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ TextProcessor
constructor
A new instance of TextProcessor.
- #process(string) ⇒ Object
- #process_file(path) ⇒ Object
- #process_stream(stream) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TextProcessor
Returns a new instance of TextProcessor.
9 10 11 |
# File 'lib/md_inc.rb', line 9 def initialize(={}) @options = end |
Instance Attribute Details
#root ⇒ Object
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 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 |