w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to iterate through a yaml hash structure in ruby?

As per your yaml file it you should get the below Hash from the line config_options = YAML.load_file(file_name)

config_options = { 'source_and_target_cols_map' =>
 [  { 'com_id' => 'community_id',
    'report_dt' => 'note_date',
    'sitesection' => 'site_section',
    'visitor_cnt' => 'visitors',
    'visit_cnt' => 'visits',
    'view_cnt' => 'views',
    'new_visitor_cnt' => 'new_visitors' }
  ]}

Then to iterate through you can take the below approach:

config_options['source_and_target_cols_map'][0].each {|k,v| key
= k,value = v}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.