Different actions on different lines of a string in RUBY -


i have following string:

aaaaaa; bbbbbbbb cccccc; cccccccc dddddd; dddddddd 

i need take different action in respect different lines. more precisely, must something-1 first line, something-2 other, , something-3 last one. pseudo code:

out.each_line { |ln|     if ln first        somenthing-1    end     if ln others        somenthing-2    end     if ln last        somenthing-3    end  } 

how about:

lines = out.lines do_something_1(lines.first)  lines[1..-2].each |line|   do_something_2(line) end  do_something_3(lines.last) 

this code action on first line, other action on lines except first , last, , third action on last line.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -