Skip to content

Instantly share code, notes, and snippets.

@oelmekki
Forked from MaximeD/flexion.rb
Created October 7, 2011 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oelmekki/1271528 to your computer and use it in GitHub Desktop.
Save oelmekki/1271528 to your computer and use it in GitHub Desktop.
flexion.rb
#!/usr/bin/ruby
# encoding: utf-8
class Grammar
Pronoms = [ "je", "tu", "il/elle", "nous", "vous", "ils/elles" ] ;
Terminaisons_1 = [ "e", "es", "e", "ons", "ez", "ent" ] ;
Terminaisons_2 = [ "is", "is", "it", "issons", "issez", "issent" ] ;
def conjugate( verb )
unless verb =~ /(e|i)r$/
puts "Ceci n'est pas un verbe du premier ou du second groupe !"
exit 1
end
terminaisons = $1 == 'e' ? Terminaisons_1 : Terminaisons_2
puts "\nLes formes du verbe #{verb} au présent de l'indicatif sont :\n"
inf = verb.gsub(/.{2}$/, "")
Pronoms.each_index do |x|
puts Pronoms[x] + " " + inf + terminaisons[x] + "\n"
end
end
end
puts "Entrez un verbe du 1er ou 2nd groupe :\n"
Grammar.new.conjugate gets.chomp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment