Class: Wordz::Generator
- Inherits:
-
Object
- Object
- Wordz::Generator
- Includes:
- PostProcessor
- Defined in:
- lib/wordz/generator.rb
Defined Under Namespace
Classes: UndefinedMacroError, UndefinedReceiverError
Constant Summary collapse
- ROOT_NODE =
"<root>".freeze
Constants included from PostProcessor
PostProcessor::NO_SPACE_BEFORE, PostProcessor::POST_PROCESSED_PHRASES
Instance Attribute Summary collapse
-
#grammar ⇒ Object
readonly
Returns the value of attribute grammar.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#subjects ⇒ Object
readonly
Returns the value of attribute subjects.
Instance Method Summary collapse
- #call(root_node = nil) ⇒ Object
-
#initialize(grammar: {}, subjects: {}) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(grammar: {}, subjects: {}) ⇒ Generator
Returns a new instance of Generator.
11 12 13 14 15 |
# File 'lib/wordz/generator.rb', line 11 def initialize(grammar: {}, subjects: {}) @output = [] @subjects = subjects @grammar = grammar end |
Instance Attribute Details
#grammar ⇒ Object (readonly)
Returns the value of attribute grammar.
7 8 9 |
# File 'lib/wordz/generator.rb', line 7 def grammar @grammar end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/wordz/generator.rb', line 7 def output @output end |
#subjects ⇒ Object (readonly)
Returns the value of attribute subjects.
7 8 9 |
# File 'lib/wordz/generator.rb', line 7 def subjects @subjects end |
Instance Method Details
#call(root_node = nil) ⇒ Object
17 18 19 20 |
# File 'lib/wordz/generator.rb', line 17 def call(root_node = nil) root_node ||= ROOT_NODE post_process(generate_list(root_node)) end |