Skip to content

Instantly share code, notes, and snippets.

@AlexandrBasan
Created April 9, 2015 00:20
Show Gist options
  • Save AlexandrBasan/e428025c9e9f389fe17d to your computer and use it in GitHub Desktop.
Save AlexandrBasan/e428025c9e9f389fe17d to your computer and use it in GitHub Desktop.
Ruby find all elements between two symbols
<% array_table = a.scan(/\((.*?)\ =>/) %>
<% array_index = a.scan(/\[(.*?)\]/) %>
<% com = "" %>
<% array_table.length.times do |element| %>
<% if com != array_table[element].join(', ')%>
<!-- Add commit -->
# <%= array_table[element].join(', ') %></br>
<% end %>
<!-- Text construction for output -->
add_index :<%= array_table[element].join(', ') %>, :<%= array_index[element].join(', ') %></br>
<% com = array_table[element].join(', ') %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment