Class: TermNote::Show
- Inherits:
-
Object
- Object
- TermNote::Show
- Defined in:
- lib/termnote/show.rb,
lib/termnote/show/key.rb
Defined Under Namespace
Modules: Key
Instance Attribute Summary collapse
- #pane ⇒ Object
-
#panes ⇒ Object
Returns the value of attribute panes.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #add(pane) ⇒ Object
- #backward ⇒ Object
- #close ⇒ Object
- #forward ⇒ Object
- #header ⇒ Object
-
#initialize ⇒ Show
constructor
A new instance of Show.
- #position ⇒ Object
- #start ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize ⇒ Show
Returns a new instance of Show.
8 9 10 |
# File 'lib/termnote/show.rb', line 8 def initialize @panes ||= [] end |
Instance Attribute Details
#pane ⇒ Object
18 19 20 |
# File 'lib/termnote/show.rb', line 18 def pane @pane || panes.first end |
#panes ⇒ Object
Returns the value of attribute panes.
5 6 7 |
# File 'lib/termnote/show.rb', line 5 def panes @panes end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/termnote/show.rb', line 5 def state @state end |
Instance Method Details
#add(pane) ⇒ Object
12 13 14 15 16 |
# File 'lib/termnote/show.rb', line 12 def add(pane) raise ArgumentError, "Pane required" if pane.nil? panes << pane pane.show = self end |
#backward ⇒ Object
50 51 52 |
# File 'lib/termnote/show.rb', line 50 def backward @pane = panes[position - 1] || panes.last end |
#close ⇒ Object
38 39 40 |
# File 'lib/termnote/show.rb', line 38 def close @state = false end |
#forward ⇒ Object
46 47 48 |
# File 'lib/termnote/show.rb', line 46 def forward @pane = panes[position + 1] || panes.first end |
#header ⇒ Object
42 43 44 |
# File 'lib/termnote/show.rb', line 42 def header "[#{position + 1}/#{total}] - #{panes.first.title}\n".bold end |
#position ⇒ Object
22 23 24 |
# File 'lib/termnote/show.rb', line 22 def position panes.index pane end |
#start ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/termnote/show.rb', line 30 def start @state = true while @state pane.call $stdout.winsize Key.send @command, self if Key::KEYS.include? capture_command end end |
#total ⇒ Object
26 27 28 |
# File 'lib/termnote/show.rb', line 26 def total panes.size end |