Method: Converter.name2uri

Defined in:
lib/csv2rdf/converter.rb

.name2uri(name, capitalize = FALSE) ⇒ Object

Turn any string into a URI component, useful for creating URIs from names and titles. The conversion is based on ActiveSupport’s parameterize method.

Attributes

  • name - the string to be converted

  • capitalize - if TRUE, the individual components of the name will be capitalized

Examples

Converter.name2uri("Knud Möller")
 => "knud-moller"

Converter.name2uri("Knud Möller", TRUE)
 => "Knud-Moller"


63
64
65
66
67
68
69
# File 'lib/csv2rdf/converter.rb', line 63

def Converter.name2uri(name, capitalize=FALSE)
  name = name.parameterize.downcase
  if capitalize
    name = name.split("-").map { |x| x.capitalize }.join("-")
  end
  return name
end