<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kentaro Kuribayashi</title>
    <description>The latest articles on DEV Community by Kentaro Kuribayashi (@kentaro).</description>
    <link>https://dev.to/kentaro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F41307%2Feced0c97-2b6d-44d4-b827-193f2f90adce.jpeg</url>
      <title>DEV Community: Kentaro Kuribayashi</title>
      <link>https://dev.to/kentaro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kentaro"/>
    <language>en</language>
    <item>
      <title>Generating Currency-code-like Name in Ruby</title>
      <dc:creator>Kentaro Kuribayashi</dc:creator>
      <pubDate>Thu, 16 Nov 2017 06:47:34 +0000</pubDate>
      <link>https://dev.to/kentaro/generating-currency-code-like-name-in-ruby-c6a</link>
      <guid>https://dev.to/kentaro/generating-currency-code-like-name-in-ruby-c6a</guid>
      <description>&lt;p&gt;Various currencies around. Moreover, rising of crypto currencies increases the number of currency-like stores of value. We will dare to add some into it. At the time, naming currency is a problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the Currency Codes?
&lt;/h2&gt;

&lt;p&gt;ISO 4217 delineates how to shorten currency name; currency codes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The first two letters of the code are the two letters of the ISO 3166-1 alpha-2 country codes (an omission) and the third is usually the initial of the currency itself. So Japan's currency code is JPY—JP for Japan and Y for yen.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/ISO_4217"&gt;ISO 4217 - Wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Currency Codes for Smart Tokens
&lt;/h2&gt;

&lt;p&gt;Since I had wanted similar one for original currencies backed by smart tokens, I hacked up a tiny library for Ruby named &lt;code&gt;currency_coder&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pepabo/currency_coder"&gt;currency_coder gem&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This library converts arbitrary strings (e.g. your name) to currency-code-like short name as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;cc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;CurrencyCoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;

&lt;span class="n"&gt;currency_map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"osamu"&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"OSM"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"mayoto"&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"MYT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"kurotaki"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"KRT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"putchom"&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"PTM"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"antipop"&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"ATP"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"jitsuzon"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"JZN"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;currency_map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;assert_equal&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_currency_code&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's create your own currency using this library!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>cryptocurrency</category>
    </item>
  </channel>
</rss>
