title: How do I split a string into three parts?
body: <p>I have the string <code>"001-1776591-7"</code>, and I want to divide it into 3 parts, <code>"-"</code> being the <code>split</code> parameter.</p>
  
  <p>I have already created two methods, for the first and last, but what about the second part of the string, how can I get that?</p>
  
  <hr>
  
  <p>More Info:</p>
  
  <p>I created the two methods in my Class, but when loading the view I get an error, details below:</p>
  
  <pre><code>  def serie
        @serie || cedula.to_s.split('-').[0] : @serie
    end
  
    def identificador
        @identificador || cedula.to_s.split('-').[1] : @identificador
   end
  
   def verificador
        @verificador || cedula.to_s.split('-').[2] : @verificador
   end
  
  
  SyntaxError in TecnicosController#index
  
  /home/lurraca/Desktop/rails_project/ArLink/app/models/tecnico.rb:7: syntax error, unexpected '['
            @serie || cedula.to_s.split('-').[0] : @serie
                                             ^
  /home/lurraca/Desktop/rails_project/ArLink/app/models/tecnico.rb:11: syntax error, unexpected '['
  ...dor || cedula.to_s.split('-').[1] : @identificador
  ...                              ^
  /home/lurraca/Desktop/rails_project/ArLink/app/models/tecnico.rb:15: syntax error, unexpected '['
            @verificador || cedula.to_s.split('-').[2] : @verificador
  </code></pre>