class GemFootprintAnalyzer::Formatters::Tree::Entry

Formatter helper class representing a single results require entry.

Constants

BUNDLER_RUNTIME

Public Class Methods

new(entry_hash, options = {}) click to toggle source

@param entry_hash [Hash<Symbol>] Hash with a single require analysis @param options [Hash<Symbol>]

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 14
def initialize(entry_hash, options = {})
  @entry_hash = entry_hash
  @options = options
end

Public Instance Methods

formatted_name() click to toggle source

@return [String] Formatted require name

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 42
def formatted_name
  "#{name}#{debug_parent}"
end
name() click to toggle source

@return [String] Require name

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 20
def name
  @entry_hash[:name]
end
parent() click to toggle source

@return [String] Formatted parent require name

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 25
def parent
  @entry_hash[:parent_name]
end
rss() click to toggle source

@return [Integer] Formatted RSS value

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 36
def rss
  rss = @entry_hash.dig(:rss, :mean)
  rss && rss.round
end
time() click to toggle source

@return [Integer] Formatted time value

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 30
def time
  time = @entry_hash.dig(:time, :mean)
  time && time.round
end
top_level?() click to toggle source

@return [Bool] Is the entry a Gem or original require to be analyzed

# File lib/gem_footprint_analyzer/formatters/tree.rb, line 47
def top_level?
  parent.nil? || parent == BUNDLER_RUNTIME
end

Private Instance Methods

debug_parent() click to toggle source
# File lib/gem_footprint_analyzer/formatters/tree.rb, line 53
def debug_parent
  return unless @options[:debug]

  " (#{parent})"
end