Skip to content

Instantly share code, notes, and snippets.

@oieioi
Last active August 29, 2015 14:01
Show Gist options
  • Save oieioi/de39c2edcc1995682500 to your computer and use it in GitHub Desktop.
Save oieioi/de39c2edcc1995682500 to your computer and use it in GitHub Desktop.
給料を500円玉の重さにして返す
#!/usr/bin/env coffee
argv = require 'argv'
getSalaryMass = (salary, {mass, coin} = {})->
mass = mass or 7
coin = coin or 500
"#{(salary / coin) * mass}"
argv.option [
{
name: 'coin'
short: 'c'
description: '小銭の単位(yen)'
type: 'int'
},{
name: 'weight'
short: 'w'
description: '小銭の重さ(g)'
type: 'int'
}
]
args = argv.run()
result = getSalaryMass args.targets[0],
mass: args.options.weight
coin: args.options.coin
console.log result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment