Class: Yobi::ResticOutput::LazyList

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Enumerable[Elem]
Defined in:
lib/yobi/restic_output.rb,
sig/yobi.rbs

Overview

:nodoc:

Constant Summary collapse

INSPECT_PREVIEW_SIZE =

Returns:

11

Instance Method Summary collapse

Constructor Details

#initialize(output, offsets, transform) ⇒ LazyList

Returns a new instance of LazyList.

Parameters:



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

#eachvoid #eachEnumerator[Elem, void]

Overloads:

  • #eachvoid

    This method returns an undefined value.

  • #eachEnumerator[Elem, void]

    Returns:

Yields:

Yield Parameters:

  • item (Elem)

Yield Returns:

  • (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

#inspectObject



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

#sizeInteger Also known as: length

Returns:



150
151
152
# File 'lib/yobi/restic_output.rb', line 150

def size
  @offsets.size
end