YAML Help required

I Have below YAML file.

signin:
element_1:
ios_id: ios_id_1
android_id: android_id_1
element_2:
ios_id: ios_id_2
android_id: android_id_2

I am trying to achieve is that,
When I load the YAML file, I have to load environment related id only.
For ex, on execution If I pass “IOS” then I have to create the hash
which will load only “ios” ids not android.

Hash Output should be:

Hash[“signin”][“element_1”] => ios_id_1

I am new to yaml and ruby. Can someone guide me through this?

Shrikant Karamkar wrote in post #1168897:

Hash Output should be:

Hash[“signin”][“element_1”] => ios_id_1

I am new to yaml and ruby. Can someone guide me through this?

Yes, why not :slight_smile:

require ‘yaml’

hash = YAML.load <<_
signin:
element_1:
ios_id: ios_id_1
android_id: android_id_1
element_2:
ios_id: ios_id_2
android_id: android_id_2
_

hash[“signin”][“element_1”][‘ios_id’] # => “ios_id_1”

Look at the http://ruby-doc.org//stdlib-2.0/libdoc/yaml/rdoc/YAML.html