Class: MdEdit
- Inherits:
-
Object
- Object
- MdEdit
- Defined in:
- lib/md_edit.rb
Instance Method Summary collapse
- #find(s) ⇒ Object
-
#initialize(s = nil) ⇒ MdEdit
constructor
pass in an MD document.
- #query(s) ⇒ Object (also: #q)
- #to_h ⇒ Object
Constructor Details
#initialize(s = nil) ⇒ MdEdit
pass in an MD document
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/md_edit.rb', line 14 def initialize(s=nil) if s then parse s @h = @sections.keys.inject({}) do |r,x| r.merge(x.sub(/^#+ +/,'').downcase => 5 - x.count('#')) end @pl = PhraseLookup.new @h end end |
Instance Method Details
#find(s) ⇒ Object
29 30 31 32 |
# File 'lib/md_edit.rb', line 29 def find(s) key = @sections.keys.grep(/#{s.downcase}/i).first [key, @sections[key]] end |
#query(s) ⇒ Object Also known as: q
34 35 36 |
# File 'lib/md_edit.rb', line 34 def query(s) @pl.q s end |
#to_h ⇒ Object
40 41 42 |
# File 'lib/md_edit.rb', line 40 def to_h() @h end |