indianize 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/indianize.rb +55 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 373cfa4e330e233278acbb679a2520bbf1088016463a4b5f5ebdb434f50255ff
|
4
|
+
data.tar.gz: 8a0a9882b7c39062d370f412ab055ec61c619badef4cfb9a7ad87bc68126c8ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2314aa92e81e973f243c0c5e3205a10614ce1a7b471bb43d73cd9a91d41f09e83410c405b4207ac7e4b27f133b410600e2eed171382ec1e796c5011a91b9b3dd
|
7
|
+
data.tar.gz: 8480006f0bd5cfacafe0b8be88660399dd223dacb03af3485391a0bc1812e5f35ce155ee9057ea2e9b768a08841e1708b7936fd18154f4f1f0bda53c3d303453
|
data/lib/indianize.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
class Indianize
|
2
|
+
|
3
|
+
$reference_hash = {
|
4
|
+
10000000 => "crore",
|
5
|
+
100000 => "lakh",
|
6
|
+
1000 => "thousand",
|
7
|
+
100 => "hundred",
|
8
|
+
90 => "ninety",
|
9
|
+
80 => "eighty",
|
10
|
+
70 => "seventy",
|
11
|
+
60 => "sixty",
|
12
|
+
50 => "fifty",
|
13
|
+
40 => "forty",
|
14
|
+
30 => "thirty",
|
15
|
+
20 => "twenty",
|
16
|
+
19=>"nineteen",
|
17
|
+
18=>"eighteen",
|
18
|
+
17=>"seventeen",
|
19
|
+
16=>"sixteen",
|
20
|
+
15=>"fifteen",
|
21
|
+
14=>"fourteen",
|
22
|
+
13=>"thirteen",
|
23
|
+
12=>"twelve",
|
24
|
+
11 => "eleven",
|
25
|
+
10 => "ten",
|
26
|
+
9 => "nine",
|
27
|
+
8 => "eight",
|
28
|
+
7 => "seven",
|
29
|
+
6 => "six",
|
30
|
+
5 => "five",
|
31
|
+
4 => "four",
|
32
|
+
3 => "three",
|
33
|
+
2 => "two",
|
34
|
+
1 => "one"
|
35
|
+
}
|
36
|
+
|
37
|
+
def self.to_number(value)
|
38
|
+
"₹ " + value.round.to_s.gsub(/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/, "\\1,")
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.to_words(value)
|
42
|
+
value = value.round
|
43
|
+
$reference_hash.each do |number, word|
|
44
|
+
return "please don't enter negative money value" if value < 0
|
45
|
+
return "" if value == 0
|
46
|
+
if value.to_s.length == 1 && value/number > 0
|
47
|
+
return ("#{word}").capitalize.strip
|
48
|
+
elsif value < 100 && value/number > 0
|
49
|
+
return ("#{word} " + to_words(value%number)).capitalize.strip
|
50
|
+
elsif value/number > 0
|
51
|
+
return (to_words(value/number) + " #{word} " + to_words(value%number)).capitalize.strip
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: indianize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Himanshu G.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Convert numbers to Indian currency numbering system with seperators,
|
14
|
+
in numeric and alphabetical formats.
|
15
|
+
email: cephalus.mail@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/indianize.rb
|
21
|
+
homepage: https://github.com/commutatus/indianize
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata:
|
25
|
+
source_code_uri: https://github.com/commutatus/indianize
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.7.3
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Convert numbers to Indian currency numbering system.
|
46
|
+
test_files: []
|