Class: FakerBot::Renderer
- Inherits:
-
Object
- Object
- FakerBot::Renderer
- Defined in:
- lib/fakerbot/renderer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(hash, options, output) ⇒ Renderer
constructor
A new instance of Renderer.
Constructor Details
#initialize(hash, options, output) ⇒ Renderer
Returns a new instance of Renderer.
14 15 16 17 18 19 20 21 22 |
# File 'lib/fakerbot/renderer.rb', line 14 def initialize(hash, , output) @hash = hash @options = @output = output @crayon = Pastel.new(enabled: output.tty?) @pager = TTY::Pager.new(command: 'less -R') @screen = TTY::Screen @tree = TTY::Tree end |
Class Method Details
.call(hash, options, output) ⇒ Object
10 11 12 |
# File 'lib/fakerbot/renderer.rb', line 10 def self.call(hash, , output) new(hash, , output).call end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fakerbot/renderer.rb', line 24 def call data_tree = tree.new(build_tree) view = data_tree.render if gt_screen_height?(data_tree) output.tty? ? pager.page(view) : output.puts(view) else output.puts view end end |