Class: RailsConsolePro::Printers::SnippetCollectionPrinter

Inherits:
BasePrinter
  • Object
show all
Defined in:
lib/rails_console_pro/printers/snippet_collection_printer.rb

Overview

Printer for snippet collection results

Constant Summary collapse

PREVIEW_WIDTH =
80

Instance Attribute Summary

Attributes inherited from BasePrinter

#output, #pry_instance, #value

Instance Method Summary collapse

Methods inherited from BasePrinter

#initialize

Methods included from ColorHelper

#bold_color, #color, #method_missing, #pastel, #respond_to_missing?

Constructor Details

This class inherits a constructor from RailsConsolePro::BasePrinter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RailsConsolePro::ColorHelper

Instance Method Details



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rails_console_pro/printers/snippet_collection_printer.rb', line 9

def print
  collection = value
  print_header(collection)

  if collection.empty?
    output.puts color(config.get_color(:warning), "No snippets yet. Capture one with snippets(:add, \"User.count\")")
  else
    collection.each_with_index do |snippet, index|
      print_row(snippet, index: index)
    end
  end

  print_footer(collection)
  collection
end