Class: Idml::Render::StoryChainController
- Inherits:
-
Object
- Object
- Idml::Render::StoryChainController
- Defined in:
- lib/idml/render/story_chain_controller.rb
Overview
Threads story-rendering state across linked TextFrames in a chain. A story overflows from frame 1 → frame 2 → frame 3 etc. via PreviousTextFrame/NextTextFrame links; without chain awareness, the renderer would silently truncate overflow text.
State is per story_id (the ParentStory attribute). State is populated when a chain head renders and consumed when chain non-head frames render.
Threading granularity: paragraphs and runs. If a run partially fits in a frame, the next frame picks up where the previous left off (the partially-rendered lines stay in the previous frame; remaining lines come from re-wrapping the run).
Defined Under Namespace
Classes: State
Instance Method Summary collapse
-
#has_pending?(story_id) ⇒ Boolean
True when a story has pending content from a previous frame.
-
#initialize ⇒ StoryChainController
constructor
A new instance of StoryChainController.
-
#state_for(story_id) ⇒ Object
Returns the chain state for a story, or nil if the story has no leftover content.
-
#store_state(story_id, state) ⇒ Object
Records the chain state for a story after a frame's render.
Constructor Details
#initialize ⇒ StoryChainController
37 38 39 |
# File 'lib/idml/render/story_chain_controller.rb', line 37 def initialize @states = {} end |
Instance Method Details
#has_pending?(story_id) ⇒ Boolean
True when a story has pending content from a previous frame.
59 60 61 |
# File 'lib/idml/render/story_chain_controller.rb', line 59 def has_pending?(story_id) @states.key?(story_id) end |
#state_for(story_id) ⇒ Object
Returns the chain state for a story, or nil if the story has no leftover content. Chain heads (no predecessor) get no state — they render from scratch.
44 45 46 |
# File 'lib/idml/render/story_chain_controller.rb', line 44 def state_for(story_id) @states[story_id] end |
#store_state(story_id, state) ⇒ Object
Records the chain state for a story after a frame's render. Removes the state entirely when no content remains.
50 51 52 53 54 55 56 |
# File 'lib/idml/render/story_chain_controller.rb', line 50 def store_state(story_id, state) if state.nil? || empty_state?(state) @states.delete(story_id) else @states[story_id] = state end end |