Drobne poprawki do części ruby. Wyrzucona klasa.
This commit is contained in:
parent
904a9199eb
commit
ea72ee4a56
@ -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
|
|
@ -1,8 +1,14 @@
|
|||||||
require_relative 'crane_class'
|
#require_relative 'crane_class'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
c = Crane.new("Roman")
|
def introduce
|
||||||
c.introduce
|
puts "Hello, sir. I'm Roman the Crane."
|
||||||
c.get_words
|
end
|
||||||
puts c.words
|
|
||||||
puts h = c.if_understand
|
file = File.read('test.json')
|
||||||
c.response
|
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"]
|
||||||
|
Loading…
Reference in New Issue
Block a user