Class: Saga::Parser
- Inherits:
-
Object
- Object
- Saga::Parser
- Defined in:
- lib/saga/parser.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
Class Method Summary collapse
Instance Method Summary collapse
- #handle_author(author) ⇒ Object
- #handle_definition(definition) ⇒ Object
- #handle_story(story) ⇒ Object
- #handle_string(string) ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(input) ⇒ Object
Constructor Details
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
3 4 5 |
# File 'lib/saga/parser.rb', line 3 def document @document end |
Class Method Details
.parse(input) ⇒ Object
49 50 51 52 |
# File 'lib/saga/parser.rb', line 49 def self.parse(input) parser = new parser.parse(input) end |
Instance Method Details
#handle_author(author) ⇒ Object
17 18 19 |
# File 'lib/saga/parser.rb', line 17 def () @document. << end |
#handle_definition(definition) ⇒ Object
27 28 29 30 31 |
# File 'lib/saga/parser.rb', line 27 def handle_definition(definition) @current_section = :definitions @document.definitions[@current_header] ||= [] @document.definitions[@current_header] << definition end |
#handle_story(story) ⇒ Object
21 22 23 24 25 |
# File 'lib/saga/parser.rb', line 21 def handle_story(story) @current_section = :stories @document.stories[@current_header] ||= [] @document.stories[@current_header] << story end |
#handle_string(string) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/saga/parser.rb', line 33 def handle_string(string) return if string.strip == '' return(@current_section = :body) if string.strip == 'USER STORIES' if :title == @current_section @document.title = string.gsub(/^requirements/i, '').strip @current_section = :introduction elsif :introduction == @current_section @document.introduction << string elsif :stories == @current_section and string[0,2] == ' ' @document.stories[@current_header][-1][:notes] = string.strip else @current_header = string.strip end end |
#parse(input) ⇒ Object
12 13 14 15 |
# File 'lib/saga/parser.rb', line 12 def parse(input) @tokenizer.process(input) @document end |