1 00:00:00,270 --> 00:00:03,070 Okay, so we have our contact class here, and 2 00:00:03,070 --> 00:00:05,780 we've got this full name method which returns the full name. 3 00:00:07,030 --> 00:00:11,160 We might want to refer to somebody by their last name first, and 4 00:00:11,160 --> 00:00:12,990 then their first name. 5 00:00:12,990 --> 00:00:16,870 So let's go ahead and create that method as well. 6 00:00:19,377 --> 00:00:23,370 We'll call that last_first. 7 00:00:23,370 --> 00:00:25,080 And we can do that same thing that we did last time. 8 00:00:25,080 --> 00:00:32,582 And we can say last_name, or last_first, starts with the last_name this time. 9 00:00:32,582 --> 00:00:38,172 And then normally we will add a comma, 10 00:00:38,172 --> 00:00:43,420 and then we'll add the first name. 11 00:00:43,420 --> 00:00:46,492 And now we can do the same check for the middle name. 12 00:00:50,846 --> 00:00:52,090 We'll see if that's nil. 13 00:00:54,230 --> 00:01:01,680 And then, if it is not nil, We will add a space, 14 00:01:05,056 --> 00:01:08,530 And then we'll take just the first letter of the middle name. 15 00:01:14,271 --> 00:01:17,640 And we will add a dot at the end of that. 16 00:01:19,240 --> 00:01:22,750 And then finally we can return the last name, first name. 17 00:01:22,750 --> 00:01:27,140 So I'm gonna save that, and let's just make sure that works. 18 00:01:36,188 --> 00:01:39,040 So, we've got our two contacts in this file. 19 00:01:39,040 --> 00:01:40,780 Now, let's just run it and make sure it works okay. 20 00:01:43,137 --> 00:01:46,400 Okay, that is returning exactly what we want to. 21 00:01:48,640 --> 00:01:52,250 So now that we've got two different ways of displaying these methods, 22 00:01:52,250 --> 00:01:58,190 let's go ahead and override the two string method, so that we can call that. 23 00:02:02,570 --> 00:02:04,465 So here we go, we called to_s. 24 00:02:05,930 --> 00:02:13,250 And for right now, we'll say the format by default is going to be full_name. 25 00:02:13,250 --> 00:02:16,380 Now we can use a case statement to see what the format is. 26 00:02:20,147 --> 00:02:24,323 So, if the format is full_name, 27 00:02:24,323 --> 00:02:32,100 we can just return the full name by calling the full name method. 28 00:02:33,570 --> 00:02:38,020 When it's last name, first name, we can call the last, first method. 29 00:02:40,578 --> 00:02:47,840 And then we can do the same thing with the first name, And the last name. 30 00:02:50,767 --> 00:02:55,406 And by default, let's just go ahead and return first and 31 00:02:55,406 --> 00:02:59,380 last, which is not a method we have written yet. 32 00:03:00,380 --> 00:03:01,843 So let's go ahead and write that. 33 00:03:04,730 --> 00:03:06,721 That does not include the middle names. 34 00:03:06,721 --> 00:03:13,058 So we can just say first_name, plus space, plus last name. 35 00:03:17,421 --> 00:03:23,775 Now, we can call jason.to_s, And 36 00:03:23,775 --> 00:03:31,041 then we can call this with either full name, Or last first. 37 00:03:34,198 --> 00:03:35,246 And we'll try it again on Nick. 38 00:03:39,191 --> 00:03:43,110 And we know that the others work so let's just try calling first last on this one. 39 00:03:47,320 --> 00:03:51,770 Click down into the console, clear my screen here, and 40 00:03:51,770 --> 00:03:54,320 when we run that it appears to be working correctly. 41 00:03:55,620 --> 00:03:58,810 Now we don't necessarily need this two string method right now, but 42 00:03:58,810 --> 00:04:01,330 this will come in handy a little bit later, 43 00:04:01,330 --> 00:04:04,140 when we're writing the different parts of our address book.