Class: Peeky::Renderer::ClassDebugRender

Inherits:
Object
  • Object
show all
Defined in:
lib/peeky/renderer/class_debug_render.rb

Overview

Class Debug Render

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_info) ⇒ ClassDebugRender

Returns a new instance of ClassDebugRender.


9
10
11
12
# File 'lib/peeky/renderer/class_debug_render.rb', line 9

def initialize(class_info)
  @key_width = 30
  @class_info = class_info
end

Instance Attribute Details

#class_infoObject (readonly)

Returns the value of attribute class_info


7
8
9
# File 'lib/peeky/renderer/class_debug_render.rb', line 7

def class_info
  @class_info
end

Instance Method Details

#renderObject

Render the class interface rubocop:disable Metrics/AbcSize


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/peeky/renderer/class_debug_render.rb', line 16

def render
  output = []
  output.push class_details
  attributes = render_accessors + render_readers + render_writers

  if attributes.length.positive?
    output.push("-- Attributes #{'-' * 56}")
    output.push(*attributes)
    output.push('')
  end

  methods = render_methods

  if methods.length.positive?
    output.push("-- Public Methods #{'-' * 52}")
    output.push(*methods)
    output.push('')
  end

  output.pop if output.last == ''

  output.join("\n")
end