Module: Kernel
- Defined in:
- lib/active_explorer.rb
Instance Method Summary collapse
-
#explore(object, class_filter: nil, attribute_filter: nil, attribute_limit: nil, association_filter: nil, depth: 5) ⇒ Object
(also: #ex)
Explore object and print output to console.
-
#explore_to_file(object, file_name = nil, class_filter: nil, attribute_filter: nil, attribute_limit: nil, association_filter: nil, depth: 5) ⇒ Object
(also: #exf)
Explore object and print output to image file.
Instance Method Details
#explore(object, class_filter: nil, attribute_filter: nil, attribute_limit: nil, association_filter: nil, depth: 5) ⇒ Object Also known as: ex
Explore object and print output to console.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/active_explorer.rb', line 9 def explore(object, class_filter: nil, attribute_filter: nil, attribute_limit: nil, association_filter: nil, depth: 5) if depth <= 0 puts "Depth must larger than or equal to 1." return end if object.nil? puts "Object to be explored is `nil`." return end exploration = ActiveExplorer::Exploration.new object, depth: depth, class_filter: class_filter, attribute_filter: attribute_filter, attribute_limit: attribute_limit, association_filter: association_filter exploration.to_console nil end |
#explore_to_file(object, file_name = nil, class_filter: nil, attribute_filter: nil, attribute_limit: nil, association_filter: nil, depth: 5) ⇒ Object Also known as: exf
Explore object and print output to image file.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_explorer.rb', line 32 def explore_to_file(object, file_name = nil, class_filter: nil, attribute_filter: nil, attribute_limit: nil, association_filter: nil, depth: 5) if depth <= 0 puts "Depth must larger than or equal to 1." return end if object.nil? puts "Object to be explored is `nil`." return end file = file_name.nil? ? "#{object.class.name.downcase}_#{object.id}.png" : file_name puts "\nOutput file: #{file}\n" exploration = ActiveExplorer::Exploration.new object, depth: depth, class_filter: class_filter, attribute_filter: attribute_filter, attribute_limit: attribute_limit, association_filter: association_filter exploration.to_image file nil end |