Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How do I make variables out of the TOML file? #72

Open
DaCuteRaccoon opened this issue Mar 5, 2022 · 1 comment
Open

Question: How do I make variables out of the TOML file? #72

DaCuteRaccoon opened this issue Mar 5, 2022 · 1 comment

Comments

@DaCuteRaccoon
Copy link

This is what I have so far:

user.toml:

[user]
name = "guest"
password = "test"

main.rb:

#!/usr/bin/env ruby
require 'toml'

def clear
	Gem.win_platform? ? (system "cls") : (system "clear")
end

clear
userData = TOML.load_file("user.toml")
puts userData

Then I get the output, {"user"=>{"name"=>"guest", "password"=>"test"}}
How am I supposed to parse this, so I could just do puts user.name and get guest?

@DaCuteRaccoon
Copy link
Author

Also, sorry if this question seems really basic, I just started self-teaching myself ruby a week ago. Still getting into the concept of almost everything being an object in Ruby, after coding in JS for years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant