Method: Faker::HTML.random

Defined in:
lib/faker/default/html.rb

.random(methods) ⇒ String

Produces a random method from the methods above, excluding the methods listed in the arguments.

Examples:

Faker::HTML.random #=> returns output from a single method outlined above
Faker::HTML.random(exclude: [:table]) #=> returns output from any single method outlined above except for "table"
Faker::HTML.random(exclude: [:ordered_list, :unordered_list]) #=> returns output from any single method outlined above except for either ordered_list and unordered_list

Parameters:

  • methods (Symbol)

    Specify which methods to exclude.

Returns:



187
188
189
190
191
# File 'lib/faker/default/html.rb', line 187

def random(exclude: [])
  method_list = available_methods
  exclude.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
  send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))])
end