Class: JobSpec::RenderAsMarkdown
- Inherits:
-
Object
- Object
- JobSpec::RenderAsMarkdown
- Defined in:
- lib/job_spec/render_as_markdown.rb
Instance Attribute Summary collapse
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(role) ⇒ RenderAsMarkdown
constructor
A new instance of RenderAsMarkdown.
- #render ⇒ Object
Constructor Details
#initialize(role) ⇒ RenderAsMarkdown
Returns a new instance of RenderAsMarkdown.
5 6 7 |
# File 'lib/job_spec/render_as_markdown.rb', line 5 def initialize(role) @role = role end |
Instance Attribute Details
#role ⇒ Object (readonly)
Returns the value of attribute role.
3 4 5 |
# File 'lib/job_spec/render_as_markdown.rb', line 3 def role @role end |
Instance Method Details
#render ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/job_spec/render_as_markdown.rb', line 9 def render markdown = [] markdown << "# #{role.name}" markdown << role.description unless role.description.nil? grouped_expectations.each do |group, expectations| if group.nil? markdown << '## Expectations' unless role.expectations.empty? else markdown << "## #{group}" end expectations.map(&:values).each do |(expectation, description)| markdown << "### #{expectation[0].upcase}#{expectation[1..expectation.length]}" markdown << description unless description.nil? end end markdown.join("\n\n") end |