Class: Yobi::ResticOutput::LazyList
- Inherits:
-
Object
- Object
- Yobi::ResticOutput::LazyList
- Includes:
- Enumerable, Enumerable[Elem]
- Defined in:
- lib/yobi/restic_output.rb,
sig/yobi.rbs
Overview
:nodoc:
Constant Summary collapse
- INSPECT_PREVIEW_SIZE =
11
Instance Method Summary collapse
- #each {|item| ... } ⇒ Object
-
#initialize(output, offsets, transform) ⇒ LazyList
constructor
A new instance of LazyList.
- #inspect ⇒ Object
- #pretty_print(q) ⇒ Object
- #size ⇒ Integer (also: #length)
Constructor Details
#initialize(output, offsets, transform) ⇒ LazyList
Returns a new instance of LazyList.
137 138 139 140 141 |
# File 'lib/yobi/restic_output.rb', line 137 def initialize(output, offsets, transform) @output = output @offsets = offsets @transform = transform end |
Instance Method Details
#each ⇒ void #each ⇒ Enumerator[Elem, void]
143 144 145 146 147 148 |
# File 'lib/yobi/restic_output.rb', line 143 def each return enum_for(:each) unless block_given? preview.each { |item| yield item } @offsets[preview.size..].each { |offset| yield transform_at(offset) } end |
#inspect ⇒ Object
155 156 157 158 159 |
# File 'lib/yobi/restic_output.rb', line 155 def inspect shown = preview.first(INSPECT_PREVIEW_SIZE).map(&:inspect).join(", ") shown += ", ..." if preview.size > INSPECT_PREVIEW_SIZE "[#{shown}]" end |
#pretty_print(q) ⇒ Object
161 162 163 164 165 166 |
# File 'lib/yobi/restic_output.rb', line 161 def pretty_print(q) q.group(1, "[", "]") do q.seplist(preview.first(INSPECT_PREVIEW_SIZE)) { |item| q.pp item } q.text ", ..." if preview.size > INSPECT_PREVIEW_SIZE end end |
#size ⇒ Integer Also known as: length
150 151 152 |
# File 'lib/yobi/restic_output.rb', line 150 def size @offsets.size end |