class KLog::LogStructure::GraphNode

Attributes

config[RW]
log_structure[R]

Public Class Methods

for(log_structure, graph, graph_path) click to toggle source
# File lib/k_log/log_structure.rb, line 337
def for(log_structure, graph, graph_path)
  # node_config = graph_path.inject(graph, :send) # (uses deep nesting, but fails when nil is returned) https://stackoverflow.com/questions/15862455/ruby-nested-send
  # node.nil? ? null : node.send(name) || null
  node_config = graph_path.reduce(graph) do |node, name|
    result = node.send(name)

    break null if result.nil?

    result
  end

  new(log_structure, node_config)
end
new(log_structure, config) click to toggle source
# File lib/k_log/log_structure.rb, line 352
def initialize(log_structure, config)
  @log_structure = log_structure
  @config = config || OpenStruct.new
end
null() click to toggle source
# File lib/k_log/log_structure.rb, line 333
def null
  @null ||= OpenStruct.new
end

Public Instance Methods

columns() click to toggle source

table_print compatible configuration for displaying columns for an array

# File lib/k_log/log_structure.rb, line 358
def columns
  config.columns
end
filter(value) click to toggle source

Array rows are filtered via this predicate

# File lib/k_log/log_structure.rb, line 388
def filter(value)
  config.filter.call(value)
end
filter?() click to toggle source

Array rows are filtered

# File lib/k_log/log_structure.rb, line 383
def filter?
  config&.filter.respond_to?(:call)
end
heading() click to toggle source

Optional heading for the node

# File lib/k_log/log_structure.rb, line 363
def heading
  config.heading
end
heading_type() click to toggle source

Type of heading [:heading, :subheading, :section]

# File lib/k_log/log_structure.rb, line 368
def heading_type
  config.heading_type || :section
end
limited?() click to toggle source

Array rows are limited, see take

# File lib/k_log/log_structure.rb, line 398
def limited?
  config.take&.is_a?(Integer)
end
pry_at() click to toggle source

Useful in complex debug scenarios

# File lib/k_log/log_structure.rb, line 418
def pry_at
  config.pry_at || []
end
pry_at?(section) click to toggle source
# File lib/k_log/log_structure.rb, line 422
def pry_at?(section)
  pry_at.include?(section)
end
show_array_count() click to toggle source
# File lib/k_log/log_structure.rb, line 431
def show_array_count
  log_structure.show_array_count
end
skip?() click to toggle source

Skip this node

# File lib/k_log/log_structure.rb, line 413
def skip?
  config.skip == true
end
skip_empty?() click to toggle source

Skip empty array node (my be useful for other nodes, but not yet)

# File lib/k_log/log_structure.rb, line 427
def skip_empty?
  config.skip_empty == true
end
sort() click to toggle source

Use array.sort?

# File lib/k_log/log_structure.rb, line 408
def sort
  config.sort
end
sort?() click to toggle source

Array rows are sorted using .sort

# File lib/k_log/log_structure.rb, line 403
def sort?
  config&.sort.respond_to?(:call)
end
take() click to toggle source

How any array rows to take

# File lib/k_log/log_structure.rb, line 393
def take
  config.take
end
transform(value) click to toggle source

Transform node value

# File lib/k_log/log_structure.rb, line 378
def transform(value)
  config.transform.call(value)
end
transform?() click to toggle source

Node data is to be transformed

# File lib/k_log/log_structure.rb, line 373
def transform?
  config&.transform.respond_to?(:call)
end