Class: Peeky::Renderer::ClassInterfaceYardRender

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

Overview

Render: Class Interface with YARD documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_info) ⇒ ClassInterfaceYardRender

Returns a new instance of ClassInterfaceYardRender.


27
28
29
30
31
32
# File 'lib/peeky/renderer/class_interface_yard_render.rb', line 27

def initialize(class_info)
  @class_info = class_info
  @indent = ''
  @default_param_type = 'String'
  @default_splat_param_type = 'Object'
end

Instance Attribute Details

#class_infoObject (readonly)

ClassInfo with information about the class instance to be rendered.


25
26
27
# File 'lib/peeky/renderer/class_interface_yard_render.rb', line 25

def class_info
  @class_info
end

#default_param_typeObject

Default param type when documenting positional and named parameters. Defaults to <String>


18
19
20
# File 'lib/peeky/renderer/class_interface_yard_render.rb', line 18

def default_param_type
  @default_param_type
end

#default_splat_param_typeObject

Default param type when documenting splat *parameters. Defaults to <Object>


22
23
24
# File 'lib/peeky/renderer/class_interface_yard_render.rb', line 22

def default_splat_param_type
  @default_splat_param_type
end

#indentObject

Indentation prefix as a string, defaults to ''

If you were writing a class into a file with an existing module, you may set the indent to ' ' if you wanted this render to indent by two spaces


14
15
16
# File 'lib/peeky/renderer/class_interface_yard_render.rb', line 14

def indent
  @indent
end

Instance Method Details

#renderObject

Render the class interface with YARD documentation


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/peeky/renderer/class_interface_yard_render.rb', line 35

def render
  output = []
  output.push render_start
  @indent += '  '
  output += (render_accessors + render_readers + render_writers + render_methods)
  output.pop if output.last == ''

  @indent = @indent[0..-3]

  output.push render_end

  output.join("\n")
end