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.
561 562 563 564 565 566 567 |
# File 'lib/kreator/interactive_cli.rb', line 561 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.
558 559 560 |
# File 'lib/kreator/interactive_cli.rb', line 558 def body @body end |
#expanded ⇒ Object
Returns the value of attribute expanded.
559 560 561 |
# File 'lib/kreator/interactive_cli.rb', line 559 def @expanded end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
558 559 560 |
# File 'lib/kreator/interactive_cli.rb', line 558 def role @role end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
558 559 560 |
# File 'lib/kreator/interactive_cli.rb', line 558 def title @title end |
Instance Method Details
#collapsible? ⇒ Boolean
569 570 571 |
# File 'lib/kreator/interactive_cli.rb', line 569 def collapsible? @collapsible end |
#to_s ⇒ Object
579 580 581 582 583 584 585 586 |
# File 'lib/kreator/interactive_cli.rb', line 579 def to_s return title unless collapsible? marker = ? "[-]" : "[+]" return "#{marker} #{title}" unless && !body.empty? "#{marker} #{title}\n#{body}" end |
#toggle ⇒ Object
573 574 575 576 577 |
# File 'lib/kreator/interactive_cli.rb', line 573 def toggle return unless collapsible? @expanded = ! end |