Class: AboutYml::TemplateGenerator
- Inherits:
-
Object
- Object
- AboutYml::TemplateGenerator
- Defined in:
- lib/about_yml/template_generator.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #definition_properties(item_ref) ⇒ Object
- #generate ⇒ Object
-
#initialize ⇒ TemplateGenerator
constructor
A new instance of TemplateGenerator.
Constructor Details
#initialize ⇒ TemplateGenerator
Returns a new instance of TemplateGenerator.
10 11 12 13 14 |
# File 'lib/about_yml/template_generator.rb', line 10 def initialize @schema = ::AboutYml::AboutFile.schema @properties = schema['properties'] @required = schema['required'] end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
9 10 11 |
# File 'lib/about_yml/template_generator.rb', line 9 def properties @properties end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
9 10 11 |
# File 'lib/about_yml/template_generator.rb', line 9 def required @required end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
9 10 11 |
# File 'lib/about_yml/template_generator.rb', line 9 def schema @schema end |
Instance Method Details
#definition_properties(item_ref) ⇒ Object
21 22 23 |
# File 'lib/about_yml/template_generator.rb', line 21 def definition_properties(item_ref) schema['definitions'][item_ref.split('/').last]['properties'] end |
#generate ⇒ Object
16 17 18 19 |
# File 'lib/about_yml/template_generator.rb', line 16 def generate props = properties.map { |name, defn| generate_item name, defn } "---\n# #{schema['description']}\n#\n#{props.join "\n\n"}" end |