Class: TermNote::Show
- Inherits:
-
Object
- Object
- TermNote::Show
- Defined in:
- lib/termnote/show.rb
Instance Attribute Summary collapse
-
#panes ⇒ Object
Returns the value of attribute panes.
Instance Method Summary collapse
- #add(pane) ⇒ Object
- #backward ⇒ Object
- #forward ⇒ Object
- #header ⇒ Object
-
#initialize ⇒ Show
constructor
A new instance of Show.
- #pane ⇒ Object
- #position ⇒ Object
- #start ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize ⇒ Show
Returns a new instance of Show.
5 6 7 |
# File 'lib/termnote/show.rb', line 5 def initialize @panes ||= [] end |
Instance Attribute Details
#panes ⇒ Object
Returns the value of attribute panes.
3 4 5 |
# File 'lib/termnote/show.rb', line 3 def panes @panes end |
Instance Method Details
#add(pane) ⇒ Object
9 10 11 12 13 |
# File 'lib/termnote/show.rb', line 9 def add(pane) raise ArgumentError, "Pane required" if pane.nil? panes << pane pane.show = self end |
#backward ⇒ Object
43 44 45 |
# File 'lib/termnote/show.rb', line 43 def backward @pane = panes[position - 1] || panes.last end |
#forward ⇒ Object
39 40 41 |
# File 'lib/termnote/show.rb', line 39 def forward @pane = panes[position + 1] || panes.first end |
#header ⇒ Object
47 48 49 |
# File 'lib/termnote/show.rb', line 47 def header "[#{position + 1}/#{total}] - #{panes.first.title}\n".bold end |
#pane ⇒ Object
15 16 17 |
# File 'lib/termnote/show.rb', line 15 def pane @pane || panes.first end |
#position ⇒ Object
19 20 21 |
# File 'lib/termnote/show.rb', line 19 def position panes.index pane end |
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/termnote/show.rb', line 27 def start active = true while active pane.call $stdout.winsize case command when "j" then forward when "k" then backward when "q" then active = false end end end |
#total ⇒ Object
23 24 25 |
# File 'lib/termnote/show.rb', line 23 def total panes.size end |