Class: Bookery::Processors::IncludeProcessor
- Inherits:
-
Object
- Object
- Bookery::Processors::IncludeProcessor
- Defined in:
- lib/bookery/processors/include_processor.rb
Instance Attribute Summary collapse
-
#current_dir ⇒ Object
readonly
Returns the value of attribute current_dir.
Instance Method Summary collapse
-
#initialize(cwd) ⇒ IncludeProcessor
constructor
A new instance of IncludeProcessor.
- #process(markdown) ⇒ Object
Constructor Details
#initialize(cwd) ⇒ IncludeProcessor
Returns a new instance of IncludeProcessor.
6 7 8 |
# File 'lib/bookery/processors/include_processor.rb', line 6 def initialize(cwd) @current_dir = cwd end |
Instance Attribute Details
#current_dir ⇒ Object (readonly)
Returns the value of attribute current_dir.
4 5 6 |
# File 'lib/bookery/processors/include_processor.rb', line 4 def current_dir @current_dir end |
Instance Method Details
#process(markdown) ⇒ Object
10 11 12 13 14 |
# File 'lib/bookery/processors/include_processor.rb', line 10 def process(markdown) markdown.gsub(/\b*includes::(.*)\b*/) do |match| File.read(File.join(current_dir, $1)) end end |