Class: Kreator::InteractiveCLI::TranscriptEntry
- Inherits:
-
Object
- Object
- Kreator::InteractiveCLI::TranscriptEntry
- Defined in:
- lib/kreator/interactive_cli.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#expanded ⇒ Object
Returns the value of attribute expanded.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #collapsible? ⇒ Boolean
-
#initialize(role:, title:, body: nil, collapsible: false, expanded: false) ⇒ TranscriptEntry
constructor
A new instance of TranscriptEntry.
- #to_s ⇒ Object
- #toggle ⇒ Object
Constructor Details
#initialize(role:, title:, body: nil, collapsible: false, expanded: false) ⇒ TranscriptEntry
Returns a new instance of TranscriptEntry.
442 443 444 445 446 447 448 |
# File 'lib/kreator/interactive_cli.rb', line 442 def initialize(role:, title:, body: nil, collapsible: false, expanded: false) @role = role @title = title @body = body.to_s @collapsible = collapsible @expanded = end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
439 440 441 |
# File 'lib/kreator/interactive_cli.rb', line 439 def body @body end |
#expanded ⇒ Object
Returns the value of attribute expanded.
440 441 442 |
# File 'lib/kreator/interactive_cli.rb', line 440 def @expanded end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
439 440 441 |
# File 'lib/kreator/interactive_cli.rb', line 439 def role @role end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
439 440 441 |
# File 'lib/kreator/interactive_cli.rb', line 439 def title @title end |
Instance Method Details
#collapsible? ⇒ Boolean
450 451 452 |
# File 'lib/kreator/interactive_cli.rb', line 450 def collapsible? @collapsible end |
#to_s ⇒ Object
460 461 462 463 464 465 466 467 |
# File 'lib/kreator/interactive_cli.rb', line 460 def to_s return title unless collapsible? marker = ? "[-]" : "[+]" return "#{marker} #{title}" unless && !body.empty? "#{marker} #{title}\n#{body}" end |
#toggle ⇒ Object
454 455 456 457 458 |
# File 'lib/kreator/interactive_cli.rb', line 454 def toggle return unless collapsible? @expanded = ! end |