However, the code above will solve the problem you're currently experiencing. In other words, what the OP asked isnt available in vanilla YAML, but is available via an extension mechanism defined by YAML. The same custom tag could be implemented in other languages. If you're using this as a database, you should also consider refactoring to a YAML::Store instead of a concatenated stream of YAML documents to take advantage of easier reading and writing, to provide support for transactions, and to handle file locking and prevent race conditions. I used Python because the OP said he wanted a more 'DRY' approach for his YAML, and DRY is a term most often used by Python people. (The argument parsed into the method is the name of the Sim to be deleted): def delete_sim(sim) I am planning to schedule jobs on runners based on variable from pipeline web UI. I am trying to create a method which will allow the user to delete specific Sims from the database. Users can create Sims (name, gender, life stage, trait) and that info is saved in database.yml. I have made a command line app based on some features from The Sims. Syck can also be found on github: github.FYI I am new to programming :) I am using plain Ruby (not Rails) If the solution is obvious to someone here, I'd much appreciate your insight. I can't seem to find what I'm looking for in the YAML documentation. But what I'm mainly hoping to find out is the correct command to delete data from YAML (line 5). Psych is maintained by Aaron Patterson on github: /ruby/psych When I run the code, it displays the else error, which seems to indicate that line 4 isn't right. More info ¶ ↑įor more advanced details on the implementation see Psych, and also check Was completely removed with the release of Ruby 2.0.0. The method will read the content of the file in memory, perform a 'search
0 Comments
Leave a Reply. |