Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 30, 2016 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/7ecf274d318fea1b80c700ccd3c55606 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/7ecf274d318fea1b80c700ccd3c55606 to your computer and use it in GitHub Desktop.
Task: Get subarray with "from..." keys
require 'rubygems'
require 'bundler/setup'
require 'pry-byebug'
hash = {
:text_data => "data",
:name => "name",
:from_address_select => "name from address slect",
:from_name => "name from name ",
:from_line1 => "name from line 1 ",
:from_line2 => "name from line 2",
:from_city_name => "name city name " ,
:from_state_name => "name from state name",
:from_zip => "name from zip",
:from_country => "name from country" ,
:to_address_select => "name to address select",
:to_name => "name to name n",
:to_line1 => "name ine1 ",
:to_line2 => "name line 2",
:to_city_name => "name to city name",
:to_state_name => "name to state name" ,
:to_zip => "name to zip ",
:to_country => "name to country"
}
from = hash.select{|k,v| k.to_s.start_with?("from_")}
#binding.pry
puts "this is from"
puts from
@lbvf50mobile
Copy link
Author

solved

funct! - change input intem
funct - just create new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment