Ruby On Rails 面试系列七,一个面试练习题

本文探讨了如何创建一个具备登录、账户创建、RSpec/Cucumber测试、Ajax功能和CSS的应用,并提供了代码实现及反馈,强调了设计模式、代码简洁性、可维护性和单元测试的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Write a Ruby program to first assemble a single set of records by parsing data from 3 different file formats and then display these records sorted in 3 different ways.

Details

The Data

A record consists of the following 5 fields: last name, first name, gender, date of birth and favorite color. You will be given 3 files, each containing records stored in a different format.

The pipe-delimited file lists each record as follows:
LastName | FirstName | MiddleInitial | Gender | FavoriteColor | DateOfBirth

The comma-delimited file looks like this:
LastName, FirstName, Gender, FavoriteColor, DateOfBirth

And lastly, the space-delimited file:
LastName FirstName MiddleInitial Gender DateOfBirth FavoriteColor

You may assume that the delimiters (commas, pipes and spaces) do not appear anywhere in the data values themselves. Write a Ruby program to read in records from these files and combine them into a single set of records.

Display Requirements

  • Create and display 3 different views of the recordset (see a sample here):
    • Output 1 – sorted by gender (females before males) then by last name ascending.
    • Output 2 – sorted by birth date, ascending.
    • Output 3 – sorted by last name, descending.
  • Ensure that fields are displayed in the following order: last name, first name, gender, date of birth, favorite color.
  • Display dates in the format MM/DD/YYYY.

Packaging Requirements

  • Please package the code in a zip or tar archive when you send it to us.
  • Tell us which script or rake task to run in order to produce the desired output from your program.
  • Specify what version of Ruby you’re using. You may use any official release of the CRuby interpreter.
  • You may use the core and the standard library, but no gems, except Rake. If you do use Rake, specify the version.

Solutions as well as questions and comments should be sent to us at

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值