Class: ProScribe::Extractor::Block
- Inherits:
-
Object
- Object
- ProScribe::Extractor::Block
- Defined in:
- lib/proscribe/extractor.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(options) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(options) ⇒ Block
Returns a new instance of Block.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/proscribe/extractor.rb', line 105 def initialize() [:type].downcase! body = .delete(:body) type = .delete(:type) file = to_filename([:title], [:parent]) # Build the hash thing. header = Hash[.map { |(k, v)| [k.to_s, v] }] # Extract the brief and other artifacts. body = body.split("\n") while true line = body.first if line.nil? break elsif line =~ /^(.*?): (.*?)$/ header[$1.downcase] = $2.strip body.shift elsif line.strip.empty? body.shift else brief = body.shift break end end body = body.join("\n") # Build the hash thing. header['page_type'] = type header['brief'] = brief header['inherits'] = resolve(header['inherits']) { |fname, _, _| fname } if header['inherits'] heading = YAML::dump(header).gsub(/^[\-\n]*/, '').strip heading += "\n--\n" @file = file body = Tilt.new(".md") { body }.render body = fix_links(body, from: file) @body = heading + body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
102 103 104 |
# File 'lib/proscribe/extractor.rb', line 102 def body @body end |
#file ⇒ Object
Returns the value of attribute file.
103 104 105 |
# File 'lib/proscribe/extractor.rb', line 103 def file @file end |