Class: Scripref::Parser
- Inherits:
-
Object
- Object
- Scripref::Parser
- Includes:
- BasicMethods
- Defined in:
- lib/scripref/parser.rb
Constant Summary
Constants included from BasicMethods
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #format_error ⇒ Object
-
#initialize(*mods) ⇒ Parser
constructor
A new instance of Parser.
- #inspect ⇒ Object
-
#parse(str) ⇒ Object
(also: #<<)
Parsing a string of a scripture reference.
Methods included from BasicMethods
#book_re, #chapter_re, #each_bookname, #verse_re
Constructor Details
#initialize(*mods) ⇒ Parser
Returns a new instance of Parser.
16 17 18 19 |
# File 'lib/scripref/parser.rb', line 16 def initialize *mods @mods = mods mods.each {|m| extend m} end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
11 12 13 |
# File 'lib/scripref/parser.rb', line 11 def error @error end |
Instance Method Details
#format_error ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/scripref/parser.rb', line 30 def format_error if error format("%s\n%s\n%s^", error, @scanner.string, ' ' * @scanner.pointer) else '' end end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/scripref/parser.rb', line 38 def inspect "#<#{self.class} #{@mods.inspect}>" end |
#parse(str) ⇒ Object Also known as: <<
Parsing a string of a scripture reference
23 24 25 26 27 28 |
# File 'lib/scripref/parser.rb', line 23 def parse str @scanner = StringScanner.new(str) @result = [] @error = nil start end |