Under the current rules you need a minimum of 520 paid contributions and an average yearly contribution (paid and credited) of 48 over your PRSI record to get the max State Pension. If you have a gap in your record and your average is less than 48 pa then you get a reduced pension (ranging from 98% to 40% depending of your yearly average number).
This is the current calculation model. This was/is due to change in the next few years to a simpler 1/40th for each year of contribution. But whether this new model will be implemented probably depends on a new government.