Module: Workshop

Defined in:
lib/workshop.rb

Defined Under Namespace

Classes: Program

Class Method Summary collapse

Class Method Details

.format_first_name(first) ⇒ Object



2
3
4
# File 'lib/workshop.rb', line 2

def Workshop.format_first_name(first)
    first.split(" ").map{|e| (e.split(/\-/).map{|e2| e2.capitalize}.join("-"))}.join(" ")
end

.format_full_name(name) ⇒ Object



10
11
12
13
# File 'lib/workshop.rb', line 10

def Workshop.format_full_name(name)
    tmp=name.split(" ")
    return ([Workshop.format_first_name(tmp[0])]+tmp[1..-1].map{|e| Workshop.format_last_name(e)}).join(" ")
end

.format_full_name_index(name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/workshop.rb', line 15

def Workshop.format_full_name_index(name)
    tmp=name.split(" ")
    first=[Workshop.format_first_name(tmp[0])]
    tmp.shift
    while tmp[0][-1,1]=="."
        first << Workshop.format_first_name(tmp[0])
        tmp.shift
    end
    return (tmp.map{|e| Workshop.format_last_name(e)}+first).join(" ")
end

.format_last_name(last) ⇒ Object



6
7
8
# File 'lib/workshop.rb', line 6

def Workshop.format_last_name(last)
    last.gsub(/[éèëê]/,"e").gsub(/[ïî]/,"i").gsub(/[ôö]/,"o").upcase
end

.prepare_title(title, dict = {}) ⇒ Object

For title with all upcase letters, apply the change dict allows badly transformed word to be corrected! (ex: type-i => Type-I)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/workshop.rb', line 28

def Workshop.prepare_title(title,dict={})
  mots=title.split(" ")
       if mots.map{|e| e == e.upcase}.all?
      title2=(mots[0]==mots[0].upcase ? mots[0].capitalize : mots[0])
           title2 = dict[title2] || title2
           title2 += " " + (mots[1..-1].map{|e| 
               mot2=(e==e.upcase ? e.downcase : e)
               dict[mot2] || mot2
           }.join(" "))
      Dyndoc.warn :title, [title,title2]
      return title2
       else
           return title
       end
end