Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Learning ruby basic
require 'yaml'
bot_data = {
:presubs => [
["dont", "dont"],
["youre", "you're"],
["love", "like"]
],
:responses => {
:default => [
"I don't understand.",
"what?",
"Huhhh bete?"
],
:greeting => ["Hi. I'm [name]. Want to chat?"],
:farewell => ["Good bye!"]
'hello' => [
"How's it going?",
"How do you do?"
],
'i like *' => [
"Why do you like *?",
"Wow I like * too!"
]
}
}
#Menampilkan struktur user dengan yaml
#
puts bot_data.to_yaml
#Write the yaml data to file
f = File.open(ARGV.first || 'bot_data', "w")
f.puts bot_data.to_yaml
f.close
@Pysis868

This comment has been minimized.

Copy link

@Pysis868 Pysis868 commented Apr 29, 2016

> ruby bot_data_to_yaml.rb
bot_data_to_yaml.rb:17: syntax error, unexpected tSTRING_BEG, expecting '}'
                'hello' => [
                 ^
bot_data_to_yaml.rb:17: syntax error, unexpected =>, expecting end-of-input
                'hello' => [
                          ^
> rubocop bot_data_to_yaml.rb
Inspecting 1 file
E

Offenses:

bot_data_to_yaml.rb:17:17: E: unexpected token tSTRING
(Using Ruby 2.0 parser; configure using TargetRubyVersion parameter, under AllCops)
                'hello' => [
                ^^^^^^^
bot_data_to_yaml.rb:20:18: E: unexpected token tCOMMA
(Using Ruby 2.0 parser; configure using TargetRubyVersion parameter, under AllCops)
                ],
                 ^
bot_data_to_yaml.rb:25:9: E: unexpected token tRCURLY
(Using Ruby 2.0 parser; configure using TargetRubyVersion parameter, under AllCops)
        }
        ^

1 file inspected, 3 offenses detected
  • Added comma at the end of line 16.
> ruby bot_data_to_yaml.rb

---
:presubs:
- - dont
  - dont
- - youre
  - you're
- - love
  - like
:responses:
  :default:
  - I don't understand.
  - what?
  - Huhhh bete?
  :greeting:
  - Hi. I'm [name]. Want to chat?
  :farewell:
  - Good bye!
  hello:
  - How's it going?
  - How do you do?
  i like *:
  - Why do you like *?
  - Wow I like * too!

Updated version here: GitHub Gist - Pysis868/bot_data_to_yaml.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.