Module: WashoutBuilderMethodArgumentsHelper

Defined in:
app/helpers/washout_builder_method_arguments_helper.rb

Overview

helper that is used to show the arguments of a method with their types in HTML documentation

Instance Method Summary collapse

Instance Method Details

#create_argument_element_spacer(xml, j, mlen) ⇒ String

this method will check if the current index of the argument is not last, will insert a comma then a break if the argument is followed by other arguments, and if the current index is equal to the size of argyments, will display a ')' sign


54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/washout_builder_method_arguments_helper.rb', line 54

def create_argument_element_spacer(xml, j, mlen)
  if j < (mlen - 1)
    xml.span ', '
  end
  if mlen > 1
    xml.br
  end
  return unless (j + 1) == mlen
  xml.span('class' => 'bold') { |y| y << ')' }
end

#create_html_public_method_arguments(xml, pre, input) ⇒ String

this method will go through each of the arguments print them and then check if we need a spacer after it

@see #create_method_argument_element
@see #create_argument_element_spacer

77
78
79
80
81
82
83
84
85
# File 'app/helpers/washout_builder_method_arguments_helper.rb', line 77

def create_html_public_method_arguments(xml, pre, input)
  mlen = input.size
  xml.br if mlen > 1
  return unless mlen > 0
  input.each_with_index do |element, index|
    create_method_argument_element(pre, element, mlen)
    create_argument_element_spacer(xml, index, mlen)
  end
end

#create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class) ⇒ void

This method returns an undefined value.

displayes an argument of a method as complex type and determines if is an array of types or not


38
39
40
41
42
# File 'app/helpers/washout_builder_method_arguments_helper.rb', line 38

def create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class)
  return if complex_class.nil?
  argument_content = param.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
  pre << "#{use_spacer ? spacer : ''}<a href='##{complex_class}'><span class='lightBlue'>#{argument_content}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
end

#create_method_argument_element(pre, param, mlen) ⇒ void

This method returns an undefined value.

displays the parameter of a method as argument and determines if the parameter is basic type or complex type


16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/washout_builder_method_arguments_helper.rb', line 16

def create_method_argument_element(pre, param, mlen)
  spacer = '&nbsp;&nbsp;&nbsp;&nbsp;'
  complex_class = param.find_complex_class_name
  use_spacer = mlen > 1 ? true : false
  if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
    pre << "#{use_spacer ? spacer : ''}<span class='blue'>#{param.type}</span>&nbsp;<span class='bold'>#{param.name}</span>"
  else
    create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class)
  end
end