Class: Charming::Response
- Inherits:
-
Data
- Object
- Data
- Charming::Response
- Defined in:
- lib/charming/response.rb
Overview
Response encapsulates a controller's dispatch outcome — one of render text, navigate to another route, or quit.
Rails-style factories (render, navigate, quit) serve as the public API and map to :kind values
that the Runtime interprets at the end of each event loop iteration.
escapes carries any out-of-band terminal sequences (image transmissions, clipboard writes, notifications, window-title changes) gathered during the dispatch. The Runtime flushes them straight to the backend, bypassing the line-based frame pipeline. It is empty for ordinary responses.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#escapes ⇒ Object
readonly
Returns the value of attribute escapes.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.navigate(path) ⇒ Object
Factory constructing a NavigateResponse routing to the named path (string).
-
.quit ⇒ Object
Factory constructing a QuitResponse signalling termination of the top-level event loop.
-
.render(body, escapes: []) ⇒ Object
Factory constructing a Render response for displaying body text on the current screen.
Instance Method Summary collapse
-
#navigate? ⇒ Boolean
Returns
truewhen this response is navigating to another screen or route. -
#quit? ⇒ Boolean
Returns
truewhen this response requests quitting the application.
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
11 12 13 |
# File 'lib/charming/response.rb', line 11 def body @body end |
#escapes ⇒ Object (readonly)
Returns the value of attribute escapes
11 12 13 |
# File 'lib/charming/response.rb', line 11 def escapes @escapes end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
11 12 13 |
# File 'lib/charming/response.rb', line 11 def kind @kind end |
#path ⇒ Object (readonly)
Returns the value of attribute path
11 12 13 |
# File 'lib/charming/response.rb', line 11 def path @path end |
Class Method Details
.navigate(path) ⇒ Object
Factory constructing a NavigateResponse routing to the named path (string).
19 20 21 |
# File 'lib/charming/response.rb', line 19 def self.navigate(path) new(kind: :navigate, body: "", path: path, escapes: []) end |
.quit ⇒ Object
Factory constructing a QuitResponse signalling termination of the top-level event loop.
24 25 26 |
# File 'lib/charming/response.rb', line 24 def self.quit new(kind: :quit, body: "", path: nil, escapes: []) end |
.render(body, escapes: []) ⇒ Object
Factory constructing a Render response for displaying body text on the current screen. escapes is the list of out-of-band sequences gathered during the dispatch (defaults to none).
14 15 16 |
# File 'lib/charming/response.rb', line 14 def self.render(body, escapes: []) new(kind: :render, body: body, path: nil, escapes: escapes) end |
Instance Method Details
#navigate? ⇒ Boolean
Returns true when this response is navigating to another screen or route.
29 30 31 |
# File 'lib/charming/response.rb', line 29 def navigate? kind == :navigate end |
#quit? ⇒ Boolean
Returns true when this response requests quitting the application.
34 35 36 |
# File 'lib/charming/response.rb', line 34 def quit? kind == :quit end |