I have a YAML file like this:
options:
some_option: 'foo'
which I load as a hash yaml
, on which I want to be able to use include?
to get a boolean telling whether a key exists in it or not.
To get the sub-keys of options
, I would normally use yaml["options"]["some_option"]
, however how would I find out if the YAML hash includes ["options"]["some_option"]
? You can't do something like:
if yaml.include? "options"["some_option"] # or
if yaml.include? ["options"]["some_option"] # or even
if yaml.include? yaml["options"]["some_option"]
Is there a way to retrieve the sub-key of options
in the YAML hash?