Skip to content

Instantly share code, notes, and snippets.

@itochan
Created October 12, 2013 14:41
Show Gist options
  • Save itochan/6950694 to your computer and use it in GitHub Desktop.
Save itochan/6950694 to your computer and use it in GitHub Desktop.
def month_convert(str)
if /(\d+)ヶ月/ =~ str
$1.to_i
elsif /(\d+)年/ =~ str
$1.to_i * 12
else
raise ArgumentError
end
end
month_convert("3ヶ月")
# => 3
month_convert("5年")
# => 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment