Class: KLog::LogStructure::GraphNode
- Inherits:
-
Object
- Object
- KLog::LogStructure::GraphNode
- Defined in:
- lib/k_log/log_structure.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#log_structure ⇒ Object
readonly
Returns the value of attribute log_structure.
Class Method Summary collapse
Instance Method Summary collapse
-
#columns ⇒ Object
table_print compatible configuration for displaying columns for an array.
- #debug ⇒ Object
-
#filter(value) ⇒ Object
Array rows are filtered via this predicate.
-
#filter? ⇒ Boolean
Array rows are filtered.
-
#heading ⇒ Object
Optional heading for the node.
-
#heading_type ⇒ Object
Type of heading [:heading, :subheading, :section].
-
#initialize(log_structure, config) ⇒ GraphNode
constructor
A new instance of GraphNode.
-
#limited? ⇒ Boolean
Array rows are limited, see take.
-
#pry_at ⇒ Object
Useful in complex debug scenarios.
- #pry_at?(section) ⇒ Boolean
- #show_array_count ⇒ Object
-
#skip? ⇒ Boolean
Skip this node.
-
#skip_empty? ⇒ Boolean
Skip empty array node (my be useful for other nodes, but not yet).
-
#sort ⇒ Object
Use array.sort?.
-
#sort? ⇒ Boolean
Array rows are sorted using .sort.
-
#take ⇒ Object
How any array rows to take.
-
#transform(value) ⇒ Object
Transform node value.
-
#transform? ⇒ Boolean
Node data is to be transformed.
Constructor Details
#initialize(log_structure, config) ⇒ GraphNode
Returns a new instance of GraphNode.
354 355 356 357 |
# File 'lib/k_log/log_structure.rb', line 354 def initialize(log_structure, config) @log_structure = log_structure @config = config || OpenStruct.new end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
333 334 335 |
# File 'lib/k_log/log_structure.rb', line 333 def config @config end |
#log_structure ⇒ Object (readonly)
Returns the value of attribute log_structure.
332 333 334 |
# File 'lib/k_log/log_structure.rb', line 332 def log_structure @log_structure end |
Class Method Details
.for(log_structure, graph, graph_path) ⇒ Object
340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/k_log/log_structure.rb', line 340 def for(log_structure, graph, graph_path) node_config = graph_path.reduce(graph) do |node, name| # handling the issue where name was :sleep result = node.respond_to?(name) ? node.send(name) : nil break null if result.nil? result end new(log_structure, node_config) end |
.null ⇒ Object
336 337 338 |
# File 'lib/k_log/log_structure.rb', line 336 def null @null ||= OpenStruct.new end |
Instance Method Details
#columns ⇒ Object
table_print compatible configuration for displaying columns for an array
360 361 362 |
# File 'lib/k_log/log_structure.rb', line 360 def columns config.columns end |
#debug ⇒ Object
437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/k_log/log_structure.rb', line 437 def debug l = KLog::LogUtil.new(KLog.logger) l.kv('columns', columns) if columns l.kv('heading', heading) if heading l.kv('heading_type', heading_type) if heading_type l.kv('filter?', filter?) l.kv('take', take) l.kv('limited?', limited?) l.kv('sort?', sort?) l.kv('sort', sort) l.kv('skip?', skip?) l.kv('pry_at', pry_at) l.kv('skip_empty?', skip_empty?) end |
#filter(value) ⇒ Object
Array rows are filtered via this predicate
390 391 392 |
# File 'lib/k_log/log_structure.rb', line 390 def filter(value) config.filter.call(value) end |
#filter? ⇒ Boolean
Array rows are filtered
385 386 387 |
# File 'lib/k_log/log_structure.rb', line 385 def filter? config&.filter.respond_to?(:call) end |
#heading ⇒ Object
Optional heading for the node
365 366 367 |
# File 'lib/k_log/log_structure.rb', line 365 def heading config.heading end |
#heading_type ⇒ Object
Type of heading [:heading, :subheading, :section]
370 371 372 |
# File 'lib/k_log/log_structure.rb', line 370 def heading_type config.heading_type || :section end |
#limited? ⇒ Boolean
Array rows are limited, see take
400 401 402 |
# File 'lib/k_log/log_structure.rb', line 400 def limited? config.take&.is_a?(Integer) end |
#pry_at ⇒ Object
Useful in complex debug scenarios
420 421 422 |
# File 'lib/k_log/log_structure.rb', line 420 def pry_at config.pry_at || [] end |
#pry_at?(section) ⇒ Boolean
424 425 426 |
# File 'lib/k_log/log_structure.rb', line 424 def pry_at?(section) pry_at.include?(section) end |
#show_array_count ⇒ Object
433 434 435 |
# File 'lib/k_log/log_structure.rb', line 433 def show_array_count log_structure.show_array_count end |
#skip? ⇒ Boolean
Skip this node
415 416 417 |
# File 'lib/k_log/log_structure.rb', line 415 def skip? config.skip == true end |
#skip_empty? ⇒ Boolean
Skip empty array node (my be useful for other nodes, but not yet)
429 430 431 |
# File 'lib/k_log/log_structure.rb', line 429 def skip_empty? config.skip_empty == true end |
#sort ⇒ Object
Use array.sort?
410 411 412 |
# File 'lib/k_log/log_structure.rb', line 410 def sort config.sort end |
#sort? ⇒ Boolean
Array rows are sorted using .sort
405 406 407 |
# File 'lib/k_log/log_structure.rb', line 405 def sort? config&.sort.respond_to?(:call) end |
#take ⇒ Object
How any array rows to take
395 396 397 |
# File 'lib/k_log/log_structure.rb', line 395 def take config.take end |
#transform(value) ⇒ Object
Transform node value
380 381 382 |
# File 'lib/k_log/log_structure.rb', line 380 def transform(value) config.transform.call(value) end |
#transform? ⇒ Boolean
Node data is to be transformed
375 376 377 |
# File 'lib/k_log/log_structure.rb', line 375 def transform? config&.transform.respond_to?(:call) end |