Module: Scripref::BasicMethods

Included in:
Parser, Processor
Defined in:
lib/scripref/basic_methods.rb

Overview

Mixin with methods of basic functionality

Constant Summary collapse

NUMBER_RE =
/\d+\s*/o

Instance Method Summary collapse

Instance Method Details

#book_re ⇒ Object

Regular expression to match a book



22
23
24
25
26
27
28
29
30
31
# File 'lib/scripref/basic_methods.rb', line 22

def book_re
  return @book_re if @book_re
  books_res_as_strings = []
  each_bookname do |bn|
    bn.each_name do |n|
      books_res_as_strings << (n.gsub(/([^\dA-Z])/, '\1?').gsub('.', '\.'))
    end
  end
  @book_re = Regexp.compile(books_res_as_strings.map {|s| '(\b' << s << '\b\.?\s*)' }.join('|'), nil)
end

#chapter_re ⇒ Object

Regular expression to match a chapter



12
13
14
# File 'lib/scripref/basic_methods.rb', line 12

def chapter_re
  NUMBER_RE
end

#each_bookname(&blk) ⇒ Object

Enumerator over booknames



34
35
36
# File 'lib/scripref/basic_methods.rb', line 34

def each_bookname &blk
  booknames_hash.each_value(&blk)
end

#verse_re ⇒ Object

Regular expression to match a verse



17
18
19
# File 'lib/scripref/basic_methods.rb', line 17

def verse_re
  NUMBER_RE
end