Giter Site home page Giter Site logo

zen_to_i's Introduction

ZenToI

兆までの漢数字を半角数字に変換します。 漢数字が続いていたらそれぞれ変換します。

Actions Status

Installation

install via rubygems

$ gem install zen_to_i

Or, you can use bundler. Please add this line to your application's Gemfile:

gem 'zen_to_i'

And then execute:

$ bundle

Usage

1. You can use zen_to_i command from your shell

$ zen_to_i "一二三"
123

# or you can use with pipe
$ echo "一二三" | zen_to_i
123

Please call bundle exec zen_to_i if you install this gem via bundler.

2. In your Ruby script

require 'zen_to_i'

"hoge".zen_to_i
#=> "hoge"

"一二三".zen_to_i
#=> "123"

"百三".zen_to_i
#=> "103"

"三兆五十二万四十八".zen_to_i
#=> "3000000520048"

Note that zen_to_i returns String, not Integer.

Or you can overwrite to_i method with Refinements.
This returns Integer same as default to_i method.

require "zen_to_i/refine"

using ZenToI::Refine

"一二三".zen_to_i
#=> "123"

"一二三".to_i
#=> 123

Also, you can implicitly overwrite to_i method by require "zen_to_i/string_ext".
Of course it is very dangerous. Please be careful to use it.

require "zen_to_i/string_ext"

"一二三".zen_to_i
#=> "123"

"一二三".to_i
#=> 123

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

zen_to_i's People

Contributors

iga-c avatar yamakoud avatar yoshitsugu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.