Drobne poprawki do części ruby. Wyrzucona klasa.

This commit is contained in:
Michal 2016-12-11 14:37:53 +01:00
parent 904a9199eb
commit ea72ee4a56
2 changed files with 13 additions and 36 deletions

View File

@ -1,29 +0,0 @@
require 'json'
class Crane
attr_accessor :name, :words
def initialize(name)
@name = name
end
def introduce
puts "Hello, sir. I'm #{name} the Crane."
end
def get_words
file = File.read('test.json')
@words = JSON.parse(file)
#puts words
end
def if_understand
return @words.length > 1
end
def response
file = File.read('past_forms.json')
past_formes = JSON.parse(file)
puts (if @words.values.any? { |e| @words.key(e).eql? "movement" } then "I #{past_formes[@words["movement"]] + ' ' + @words["directions"]}" else "Ooops" end)
end
end

View File

@ -1,8 +1,14 @@
require_relative 'crane_class'
#require_relative 'crane_class'
require 'json'
c = Crane.new("Roman")
c.introduce
c.get_words
puts c.words
puts h = c.if_understand
c.response
def introduce
puts "Hello, sir. I'm Roman the Crane."
end
file = File.read('test.json')
words = JSON.parse(file)
file2 = File.read('past_forms.json')
past_formes = JSON.parse(file2)
puts (if words.values.any? { |e| words.key(e).eql? "movement" } && words.length > 1 then "I #{past_formes[words["movement"]] + ' ' + words["directions"]}" else "Ooops" end)
puts words["directions"]