| 1 | package Neovim::Ext::Buffers; | ||||||||||||||||||||
| 2 | 55 | $Neovim::Ext::Buffers::VERSION = '0.01'; | |||||||||||||||||||
| 3 | 55 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 55 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 55 | ▶ | use Class::Accessor; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 55 | ▶ | use Tie::Array; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 55 | our @ISA = (qw/Class::Accessor Tie::Array/); | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 55 | __PACKAGE__->mk_accessors (qw/nvim/); | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | sub TIEARRAY | ||||||||||||||||||||
| 14 | { | ||||||||||||||||||||
| 15 | 11 | ▶ | my ($this, $nvim) = @_; | ||||||||||||||||||
|
Subroutine
TIEARRAY: called CC=2 SCAR=7.4
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 11 | ▶ | my $class = ref ($this) || $this; | ||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 18 | 11 | my $self = | |||||||||||||||||||
| 19 | { | ||||||||||||||||||||
| 20 | nvim => $nvim, | ||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 11 | return bless $self, $class; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub new | ||||||||||||||||||||
| 29 | { | ||||||||||||||||||||
| 30 | 11 | ▶ | my $this = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 11 | tie my @array, 'Neovim::Ext::Buffers', @_; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 11 | return \@array; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | sub _fetch_buffers | ||||||||||||||||||||
| 40 | { | ||||||||||||||||||||
| 41 | 0 | ▶ | my ($this) = @_; | ||||||||||||||||||
|
Subroutine
_fetch_buffers: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 42 | 0 | return $this->nvim->api->list_bufs(); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | sub FETCHSIZE | ||||||||||||||||||||
| 48 | { | ||||||||||||||||||||
| 49 | 0 | ▶ | my ($this) = @_; | ||||||||||||||||||
|
Subroutine
FETCHSIZE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 50 | 0 | return scalar (@{$this->_fetch_buffers}); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | sub FETCH | ||||||||||||||||||||
| 56 | { | ||||||||||||||||||||
| 57 | 0 | ▶ | my ($this, $number) = @_; | ||||||||||||||||||
|
Subroutine
FETCH: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | foreach my $buffer (@{$this->_fetch_buffers}) | |||||||||||||||||||
| 60 | { | ||||||||||||||||||||
| 61 | 0 | ▶ | if (tied (@{$buffer})->number == $number) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | { | ||||||||||||||||||||
| 63 | 0 | return $buffer; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | # Unknown buffer | ||||||||||||||||||||
| 68 | 0 | return undef; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =head1 NAME | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | Neovim::Ext::Buffers - Neovim Buffers class | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head1 VERSION | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | version 0.01 | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =head1 SYNPOSIS | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | use Neovim::Ext; | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | my $buffers = $nvim->buffers(); | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | my $count = scalar (@{$buffers}); # buffer count | ||||||||||||||||||||
| 87 | $buffers->[0]; # first buffer | ||||||||||||||||||||
| 88 | $buffers->[-1]; # last buffer | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =head1 DESCRIPTION | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | Remote Nvim buffers. | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =cut | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 55 | 1; | |||||||||||||||||||