fix typos, reformat and refactor an ActiveRecord model.
Simple case of refactoring ruby code, change camelize word to undescored (vice versa), proper indentation, removing trailing white spaces, etc.
Start file
Class biling_account < active_record::base
BelongTo 'person'
validate_presence_of 'name', 'costumer_vault_id'
def CreditCard
true if card_type && card_expires_on
end
def CardExpired
if CreditCard
true if card_expires_on < Time.zone.now
end
end
End
End file
class BillingAccount < ActiveRecord::Base
belongs_to :person
validates_presence_of :name, :customer_vault_id
def credit_card?
card_type && card_expires_on
end
def card_expired?
card_expires_on < Time.zone.today if credit_card?
end
end
View Diff
1,3c1,3 < Class biling_account < active_record::base < BelongTo 'person' < validate_presence_of 'name', 'costumer_vault_id' --- > class BillingAccount < ActiveRecord::Base > belongs_to :person > validates_presence_of :name, :customer_vault_id 5,6c5,6 < def CreditCard < true if card_type && card_expires_on --- > def credit_card? > card_type && card_expires_on 9,12c9,10 < def CardExpired < if CreditCard < true if card_expires_on < Time.zone.now < end --- > def card_expired? > card_expires_on < Time.zone.today if credit_card? 14c12 < End --- > end
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 25 remaining solutions by signing in and submitting your own entry
#26 Leon Li / @tubieyi - Score: 137 - 12/31/10 @ 20:24
~w~al<Esc>f_x~ww~f_x~ww~jxbbr:bguwftis_<Esc>jas<Esc>wr:wwxwr:llrufurowxjjguiwfci_<Esc>A?<Esc>jI<Esc>hdtcjjjwguwfei_<Esc>A?<Esc>jguiwfci_<Esc>A?<Esc>ddpkhhdtcJbcwtoday<Esc>jddjlD0~ZZ
0 comments
#27 Juan C. Muller / @juancmuller - Score: 137 - 01/01/11 @ 20:58
<C-V>GEuw~al<Esc>f_x~2W~f_xRR<Esc>fb~/T<CR>vcs_t<Esc>jis<Esc>:%s/'\(\w*\)'/:\1/g<CR>fcfcau<Del><Right><Right>o<Del><Esc>/C<CR>~nvc_c<Esc>A?<Esc>+2h3dwn~fEvc_e<Esc>A?<Esc>jdd6h3dw$cawtoday if cr<C-N>?<Esc>jddGA<BS><BS><Esc>ZZ
0 comments
#28 Aurélien Delahaye / @alkove - Score: 139 - 01/01/11 @ 10:24
:%s/'\(\w*\)'/:\1/g<CR>H~w~al<Esc>f_x~2w~<0xc2><0xa0>f_x~2w~+~fTss_t<Esc>jis<Esc>wforufuro2ja?<Esc>FCs_c<Esc>FCrc"ay$j2Xdtc3jw~fEs_e<kEnd>?<Esc>jdd6Xdtc$xxxatoday if <Esc>"apjddj$xx0~ZZ
0 comments
#29 Brendan Taylor / @beect - Score: 141 - 04/26/11 @ 15:47
VGuw~al<Esc>f_x~2w~f_x~2w~jxBr:?t<CR>is_<Esc>jlis<Esc>Wr:wwxwr:llrulllroA<BS><Esc>2jA?<Esc>4hi_<Esc>j04ldtc4jddpjdd3kfefei_<Esc>A?<Esc>j04ldtcWwrT3wlcwtoday<Esc>J/t<CR>li_<Esc>A?<Esc>GA<BS><BS><Esc>:w<BS><BS>ZZ
0 comments
#30 drio / @drio - Score: 150 - 01/12/11 @ 05:27
<C-V>GEuw~al<Esc>f_x~fa~f_x~fb~/T<CR>vcs_t<Esc>jis<Esc>:%s/'\(\w*\)'/:\1/g<CR>fcfcau<Esc>lxfuro/C~<Esc><BS><Esc>/C<CR>~nvc_cA<BS><Esc>A?<Esc>+2h3dwn~fEvc_e<Esc>A?<Esc>jdd6h3dw$cawtoday if cr<C-N>?<Esc>jjdd<Esc>ukddGA<BS><BS><Esc>ZZ
0 comments
#31 Kevin Webster / @rabidpraxis - Score: 158 - 01/02/11 @ 16:17
~w~x2Prlf_x~2w~f_a<Esc>x~fb~w~tTprspl~wqqr:elxqwt_prsw@qw@qForufuro?C<BS><BS>/C<CR>~f<Esc>tCpr_n~$pr?wdtci<BS><BS><Esc>n~fEi_<Esc>l~$a?<Esc>ndddtci<BS><BS><BS><BS><BS><BS><Esc>$cbtoday if<Esc>;ls credit_card?<Esc>jddw~$xxZZ
0 comments
#32 Nick Klauer / @klauern - Score: 178 - 01/01/11 @ 22:01
~w~al<Esc>f_x~ww~f_x~ww~:%s(<BS>/'\(\w*\)'/:\`1<BS><BS>1/g<CR>k~fTxi_<BS>s_t<Esc>jis<Esc>wwwwwlrulllrojjbbw~fCxi_c<Esc>$a?<Esc>jbbbblbjhhd3wjjjll~fExi_e<Esc>$a?<Esc>jddjddklld3ww$hdwdlatoday if credit_card?<Esc>jjb~lllll<BS>D:x<CR>
0 comments
VimGolf