Class: Docforge::Brief
- Inherits:
-
Object
- Object
- Docforge::Brief
- Defined in:
- lib/docforge/brief.rb
Overview
Typed wrapper around the JSON payload the model returns. Gives the renderer a consistent API and lets us validate up front instead of crashing mid-render with a NoMethodError on ‘nil`.
Constant Summary collapse
- REQUIRED_KEYS =
%w[ title value_statement problem_paragraph capabilities worked_example design_decisions why_hard_paragraph capabilities_table sharable ].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #capabilities ⇒ Object
- #capabilities_table ⇒ Object
- #design_decisions ⇒ Object
- #future_extensions ⇒ Object
-
#initialize(data) ⇒ Brief
constructor
A new instance of Brief.
- #metadata ⇒ Object
- #numbers ⇒ Object
- #problem ⇒ Object
- #pull_quote_italic ⇒ Object
- #sharable ⇒ Object
- #stack_and_credits ⇒ Object
- #title ⇒ Object
- #value_statement ⇒ Object
- #why_hard ⇒ Object
- #worked_example ⇒ Object
Constructor Details
#initialize(data) ⇒ Brief
Returns a new instance of Brief.
17 18 19 20 |
# File 'lib/docforge/brief.rb', line 17 def initialize(data) @data = data validate! end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/docforge/brief.rb', line 15 def data @data end |
Instance Method Details
#capabilities ⇒ Object
27 |
# File 'lib/docforge/brief.rb', line 27 def capabilities; @data["capabilities"] || []; end |
#capabilities_table ⇒ Object
31 |
# File 'lib/docforge/brief.rb', line 31 def capabilities_table; @data["capabilities_table"] || []; end |
#design_decisions ⇒ Object
29 |
# File 'lib/docforge/brief.rb', line 29 def design_decisions; @data["design_decisions"] || []; end |
#future_extensions ⇒ Object
33 |
# File 'lib/docforge/brief.rb', line 33 def future_extensions; @data["future_extensions"] || []; end |
#metadata ⇒ Object
25 |
# File 'lib/docforge/brief.rb', line 25 def ; @data["metadata"] || {}; end |
#numbers ⇒ Object
32 |
# File 'lib/docforge/brief.rb', line 32 def numbers; @data["numbers"] || []; end |
#problem ⇒ Object
26 |
# File 'lib/docforge/brief.rb', line 26 def problem; @data["problem_paragraph"]; end |
#pull_quote_italic ⇒ Object
24 |
# File 'lib/docforge/brief.rb', line 24 def pull_quote_italic; @data["pull_quote_italic"]; end |
#sharable ⇒ Object
35 |
# File 'lib/docforge/brief.rb', line 35 def sharable; @data["sharable"] || {}; end |
#stack_and_credits ⇒ Object
34 |
# File 'lib/docforge/brief.rb', line 34 def stack_and_credits; @data["stack_and_credits"] || {}; end |
#title ⇒ Object
22 |
# File 'lib/docforge/brief.rb', line 22 def title; @data["title"]; end |
#value_statement ⇒ Object
23 |
# File 'lib/docforge/brief.rb', line 23 def value_statement; @data["value_statement"]; end |
#why_hard ⇒ Object
30 |
# File 'lib/docforge/brief.rb', line 30 def why_hard; @data["why_hard_paragraph"]; end |
#worked_example ⇒ Object
28 |
# File 'lib/docforge/brief.rb', line 28 def worked_example; @data["worked_example"] || {}; end |