Class: IdiomExplorer
- Inherits:
-
Object
- Object
- IdiomExplorer
- Defined in:
- lib/words_and_idioms/idiom_explorer.rb,
lib/words_and_idioms/zz - idiom_explorer_old.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ IdiomExplorer
constructor
A new instance of IdiomExplorer.
Constructor Details
#initialize ⇒ IdiomExplorer
Returns a new instance of IdiomExplorer.
3 4 5 |
# File 'lib/words_and_idioms/zz - idiom_explorer_old.rb', line 3 def initialize end |
Class Method Details
.idiom_routine ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/words_and_idioms/zz - idiom_explorer_old.rb', line 6 def self.idiom_routine IdiomList.new counter = 1 IdiomList.all.each do |hash| hash.each do |k,v| puts "#{counter}. #{k}" counter += 1 end end puts " " puts "Which idiom would you like me to define?" puts " " input = (gets.chomp).to_i puts " " puts "Interesting choice. Here is the definition:".magenta puts " " hash_value = IdiomList.all[input - 1] hash_idiom = hash_value.keys[0] hash_def = hash_value[hash_idiom] puts "#{hash_idiom.upcase.yellow}: #{hash_def}" puts " " puts " " puts "Would you like to see this word in context?".light_blue puts "Y/N" context = gets.chomp.downcase if context == "y" self.usage puts " " puts " " puts @usage_array[input - 1].green puts " " puts " " end end |
.show_idiom ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/words_and_idioms/idiom_explorer.rb', line 4 def self.show_idiom puts "Which idiom would you like me to define?" puts " " input = ((gets.chomp).to_i - 1) idiom = Idiom.all[input] puts " " puts "Interesting choice. Here is the definition:".magenta puts " " puts idiom.name.upcase.yellow + ": " + idiom.definition puts " " puts "Would you like to see this word in context?".light_blue puts "Y/N" context = gets.chomp.downcase if context == "y" puts " " puts idiom.usage.green puts " " end end |