Class: FBO::Interpreter
- Inherits:
-
Object
- Object
- FBO::Interpreter
- Defined in:
- lib/fbo/interpreter.rb
Instance Method Summary collapse
-
#each_notice(&block) ⇒ Object
Walk through all notices in the given file.
-
#initialize(file) ⇒ Interpreter
constructor
A new instance of Interpreter.
-
#next_notice {|notice_text, notice_node| ... } ⇒ Object
Get the next notice from the file.
Constructor Details
#initialize(file) ⇒ Interpreter
3 4 5 6 |
# File 'lib/fbo/interpreter.rb', line 3 def initialize(file) @file = file @parser = Parser.new end |
Instance Method Details
#each_notice(&block) ⇒ Object
Walk through all notices in the given file. For each notice, yield passing the text block and structure as args.
11 12 13 14 15 16 |
# File 'lib/fbo/interpreter.rb', line 11 def each_notice(&block) while true string, structure = next_notice(&block) break unless string end end |
#next_notice {|notice_text, notice_node| ... } ⇒ Object
Get the next notice from the file. If a block is given, yield passing the text block and structure as args. Return the text and structure.
22 23 24 25 26 27 28 29 |
# File 'lib/fbo/interpreter.rb', line 22 def next_notice(&block) return unless notice_text = next_notice_string return if notice_text.empty? notice_node = parse_notice(notice_text) yield notice_text, notice_node if block_given? return notice_text, notice_node end |