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.
637 638 639 640 641 642 643 |
# File 'lib/kreator/interactive_cli.rb', line 637 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.
634 635 636 |
# File 'lib/kreator/interactive_cli.rb', line 634 def body @body end |
#expanded ⇒ Object
Returns the value of attribute expanded.
635 636 637 |
# File 'lib/kreator/interactive_cli.rb', line 635 def @expanded end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
634 635 636 |
# File 'lib/kreator/interactive_cli.rb', line 634 def role @role end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
634 635 636 |
# File 'lib/kreator/interactive_cli.rb', line 634 def title @title end |
Instance Method Details
#collapsible? ⇒ Boolean
645 646 647 |
# File 'lib/kreator/interactive_cli.rb', line 645 def collapsible? @collapsible end |
#to_s ⇒ Object
655 656 657 658 659 660 661 662 |
# File 'lib/kreator/interactive_cli.rb', line 655 def to_s return title unless collapsible? marker = ? "[-]" : "[+]" return "#{marker} #{title}" unless && !body.empty? "#{marker} #{title}\n#{body}" end |
#toggle ⇒ Object
649 650 651 652 653 |
# File 'lib/kreator/interactive_cli.rb', line 649 def toggle return unless collapsible? @expanded = ! end |