Class: MarkdownGenerator
- Inherits:
-
Object
- Object
- MarkdownGenerator
- Defined in:
- lib/relationships/markdown_generator.rb
Instance Attribute Summary collapse
-
#models ⇒ Object
Returns the value of attribute models.
-
#relationships_path ⇒ Object
Returns the value of attribute relationships_path.
Class Method Summary collapse
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(args = {}) ⇒ MarkdownGenerator
constructor
A new instance of MarkdownGenerator.
- #output! ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ MarkdownGenerator
Returns a new instance of MarkdownGenerator.
9 10 11 12 13 |
# File 'lib/relationships/markdown_generator.rb', line 9 def initialize(args = {}) @relationships_path = Pathname.new('').join 'relationships' @models = args[:models] make_relationships_directory end |
Instance Attribute Details
#models ⇒ Object
Returns the value of attribute models.
2 3 4 |
# File 'lib/relationships/markdown_generator.rb', line 2 def models @models end |
#relationships_path ⇒ Object
Returns the value of attribute relationships_path.
2 3 4 |
# File 'lib/relationships/markdown_generator.rb', line 2 def relationships_path @relationships_path end |
Class Method Details
.output(models) ⇒ Object
4 5 6 7 |
# File 'lib/relationships/markdown_generator.rb', line 4 def self.output(models) generator = MarkdownGenerator.new models: models generator.output! end |
Instance Method Details
#file ⇒ Object
15 16 17 |
# File 'lib/relationships/markdown_generator.rb', line 15 def file @output_file ||= File.new(relationships_path.join('relationships.md'), 'w') end |
#output! ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/relationships/markdown_generator.rb', line 19 def output! models.each do |model| file.write "\n# #{model.class_name}\n" model.relationships.each do |relationshipship| file.write "* #{relationshipship}\n" end end file.close end |