@scores_raw.each do |score_raw|
# below is code if time was being sent in milliseconds
hh = ((score_raw.score.to_i)/100)/3600
mm = (hh-hh.to_i)*60
ss = (mm-mm.to_i)*60
crumbs = [hh,mm,ss]
sum = crumbs.first.to_i*3600+crumbs[1].to_i*60+crumbs.last.to_i
@scores << {:secs => sum, :hms => hh.round.to_s+":"+mm.round.to_s+":"+ss.round.to_s}
@scores_hash << {:secs => sum, :hms => hh.round.to_s+":"+mm.round.to_s+":"+ss.round.to_s}
# milliseconds case end
end
Run Code Online (Sandbox Code Playgroud)
这是我目前的代码,但我讨厌它.它看起来很乱.它不仅看起来很棒.也许某人的红宝石专家可以通过链接收集,减少等并使其看起来很好来告诉如何做到这一点?
服务器端代码:
if (Meteor.isClient) {
Meteor.subscribe("messages");
Template.hello.greeting = function () {
Messages = new Meteor.Collection("messages");
Stuff = new Meteor.Collection("stuff");
return "Welcome to feelings.";
};
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
var response = Messages.insert({text: "Hello, world!"});
var messages = Messages.find
console.log("You pressed the button", response, Messages, Stuff);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
Messages = …Run Code Online (Sandbox Code Playgroud)