Class: Woods::FlowDocument
- Inherits:
-
Object
- Object
- Woods::FlowDocument
- Defined in:
- lib/woods/flow_document.rb
Overview
Value object representing an assembled execution flow trace.
Contains an ordered list of steps from an entry point through the dependency graph, with each step holding operations extracted from source code in line order.
Instance Attribute Summary collapse
-
#entry_point ⇒ Object
readonly
Returns the value of attribute entry_point.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#max_depth ⇒ Object
readonly
Returns the value of attribute max_depth.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Class Method Summary collapse
-
.from_h(data) ⇒ FlowDocument
Reconstruct a FlowDocument from a serialized Hash.
Instance Method Summary collapse
-
#initialize(entry_point:, route: nil, max_depth: 5, steps: [], generated_at: nil) ⇒ FlowDocument
constructor
A new instance of FlowDocument.
-
#to_h ⇒ Hash
Serialize to a JSON-compatible Hash.
-
#to_markdown ⇒ String
Render as human-readable Markdown.
Constructor Details
#initialize(entry_point:, route: nil, max_depth: 5, steps: [], generated_at: nil) ⇒ FlowDocument
Returns a new instance of FlowDocument.
29 30 31 32 33 34 35 |
# File 'lib/woods/flow_document.rb', line 29 def initialize(entry_point:, route: nil, max_depth: 5, steps: [], generated_at: nil) @entry_point = entry_point @route = route @max_depth = max_depth @steps = steps @generated_at = generated_at || Time.now.iso8601 end |
Instance Attribute Details
#entry_point ⇒ Object (readonly)
Returns the value of attribute entry_point.
22 23 24 |
# File 'lib/woods/flow_document.rb', line 22 def entry_point @entry_point end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
22 23 24 |
# File 'lib/woods/flow_document.rb', line 22 def generated_at @generated_at end |
#max_depth ⇒ Object (readonly)
Returns the value of attribute max_depth.
22 23 24 |
# File 'lib/woods/flow_document.rb', line 22 def max_depth @max_depth end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
22 23 24 |
# File 'lib/woods/flow_document.rb', line 22 def route @route end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
22 23 24 |
# File 'lib/woods/flow_document.rb', line 22 def steps @steps end |
Class Method Details
.from_h(data) ⇒ FlowDocument
Reconstruct a FlowDocument from a serialized Hash.
Handles both symbol and string keys for JSON round-trip compatibility.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/woods/flow_document.rb', line 56 def self.from_h(data) data = deep_symbolize_keys(data) new( entry_point: data[:entry_point], route: data[:route], max_depth: data[:max_depth] || 5, steps: data[:steps] || [], generated_at: data[:generated_at] ) end |
Instance Method Details
#to_h ⇒ Hash
Serialize to a JSON-compatible Hash.
40 41 42 43 44 45 46 47 48 |
# File 'lib/woods/flow_document.rb', line 40 def to_h { entry_point: @entry_point, route: @route, max_depth: @max_depth, generated_at: @generated_at, steps: @steps } end |
#to_markdown ⇒ String
Render as human-readable Markdown.
Produces a document with a header showing the route and entry point, followed by one section per step with an operations table.
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/woods/flow_document.rb', line 88 def to_markdown lines = [] lines << format_header lines << '' @steps.each_with_index do |step, idx| lines << format_step(step, idx + 1) lines << '' end lines.join("\n") end |