Figured out myself:
schema = Avro::Schema.parse(SCHEMA)
dw = Avro::IO::DatumWriter.new(schema)
buffer = StringIO.new
encoder = Avro::IO::BinaryEncoder.new(buffer)
datum = Hash["name" =>name, "id" => id, "city" => city]
dw.write(datum, encoder)
buffer has the resultant avro serialized bytes.
Looks like there is no Avro client code generation in Ruby yet. We have to pass the data as Ruby hashes like I have done in for datum field.