Class: Rvim::Quickfix
- Inherits:
-
Object
- Object
- Rvim::Quickfix
- Defined in:
- lib/rvim/quickfix.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #add(entry) ⇒ Object
- #advance(direction) ⇒ Object
- #at(idx) ⇒ Object
- #clear ⇒ Object
- #current ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Quickfix
constructor
A new instance of Quickfix.
- #set(entries) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ Quickfix
Returns a new instance of Quickfix.
7 8 9 10 |
# File 'lib/rvim/quickfix.rb', line 7 def initialize @entries = [] @index = 0 end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
38 39 40 |
# File 'lib/rvim/quickfix.rb', line 38 def entries @entries end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
38 39 40 |
# File 'lib/rvim/quickfix.rb', line 38 def index @index end |
Instance Method Details
#add(entry) ⇒ Object
17 18 19 |
# File 'lib/rvim/quickfix.rb', line 17 def add(entry) @entries << entry end |
#advance(direction) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/rvim/quickfix.rb', line 47 def advance(direction) return nil if @entries.empty? @index = (@index + direction).clamp(0, @entries.size - 1) @entries[@index] end |
#at(idx) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/rvim/quickfix.rb', line 40 def at(idx) return nil if idx < 0 || idx >= @entries.size @index = idx @entries[idx] end |
#clear ⇒ Object
21 22 23 24 |
# File 'lib/rvim/quickfix.rb', line 21 def clear @entries = [] @index = 0 end |
#current ⇒ Object
34 35 36 |
# File 'lib/rvim/quickfix.rb', line 34 def current @entries[@index] end |
#each(&block) ⇒ Object
54 55 56 |
# File 'lib/rvim/quickfix.rb', line 54 def each(&block) @entries.each(&block) end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/rvim/quickfix.rb', line 30 def empty? @entries.empty? end |
#set(entries) ⇒ Object
12 13 14 15 |
# File 'lib/rvim/quickfix.rb', line 12 def set(entries) @entries = entries.dup @index = 0 end |
#size ⇒ Object
26 27 28 |
# File 'lib/rvim/quickfix.rb', line 26 def size @entries.size end |