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

Parameters:

  • xml (Builder::XmlMarkup)

    the markup builder that is used to insert HTML line breaks or span elements

  • j (Integer)

    the index of the previous argument that was displayed (

  • mlen (Integer)

    This determines how many arguments the method that is displayed has

Returns:

  • (String)

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

Parameters:

  • xml (Builder::XmlMarkup)

    the markup builder that is used to insert HTML line breaks or span elements

  • pre (Array)

    The array that holds the html that will be appended to the xml

  • input (Array)

    An array with arguments

Returns:

  • (String)

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

Parameters:

  • pre (Array)

    Array that contains the content that will be appended to the xml

  • param (WashOut::Param)

    the parameter what needs to be displayed

  • use_spacer (Bololean)

    Determines if we need a spacer when appending the html or not

  • spacer (String)

    the spacer that needs to be prepended if use_spacer is true

  • complex_class (Class)

    The name of the complex type


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

Parameters:

  • pre (Array)

    Array that contains the content that will be appended to the xml

  • param (WashOut::Param)

    the parameter what needs to be displayed

  • mlen (Integer)

    Determines if we need a spacer when appending the html or not

See Also:


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