akshar 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 000dc95cda1db1f8a88200c5c9e71ffe13ca37e9
4
- data.tar.gz: 2d92599611c2fe454ec5b3e133af1fffd33cd171
3
+ metadata.gz: df98b610e3e9c2279c9fa5dcbe903848d101faf7
4
+ data.tar.gz: 6a2d3e3c15956e3e2cd8288b839f4e915740ecd5
5
5
  SHA512:
6
- metadata.gz: eb58d8c664a2f5c892cd97bc3f5dff5bece9dfc6b620b3fdf586d465de8efd68f3c9f9500f389ee31b600697d6da526935730d8e74560213333228c4b9ea32d4
7
- data.tar.gz: b0e78aa2b2077fa96c395b51b15fce7a8a0b91ffb795d74ace4ca38f09094addd572d40117fc4030b1fb3178121f39ce6d48044bf1e7b34bd5430a8e609f87c7
6
+ metadata.gz: f8dba71b5adad10edcf5c93857826247dfe46e9fa0311ac078604d8c761561474bc261d5121bdadf33ee625304c1c4569bfc59d31638ebc6da4fecbb798be24a
7
+ data.tar.gz: 597c0a100103a7d26667ab978cd2c3022464baed22ef05fbf2bb83a8f92894991b58bb34098d183a19f28cf14022ae91d1fd6841048f996efe94b8a3a9495272
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in to_words.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ akshar (0.0.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ akshar!
16
+ bundler (~> 1.10)
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.10.5
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 anupbrt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Akshar
2
+
3
+ Convert Numbers to Nepali Words( actually...Nepali words for Money ).
4
+
5
+ e.g.
6
+
7
+ 1.to_akshar # "रुपैयाँ एक मात्र ।"
8
+
9
+ 100.to_akshar # "रुपैयाँ एक सय मात्र ।"
10
+
11
+ 101.34.to_akshar # रुपैयाँ एक सय एक, पैसा चौँतिस मात्र ।
12
+
13
+ 1231232131231.to_akshar # "रुपैयाँ बाह्र खर्ब एकत्तिस अर्ब तेईस करोड एक्काइस लाख एकत्तिस हजार दुई सय एकत्तिस मात्र ।"
14
+
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'akshar'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install akshar
31
+
32
+
33
+ ## License
34
+ Copyright (c) 2015 Anup Neupane
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
43
+ THE SOFTWARE.
44
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/akshar-0.0.1.gem ADDED
Binary file
data/akshar-0.0.2.gem ADDED
Binary file
data/akshar-0.0.3.gem ADDED
Binary file
data/akshar.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'akshar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "akshar"
8
+ spec.version = Akshar::VERSION
9
+ spec.authors = ["Anup Neupane"]
10
+ spec.email = ["anupbrt@outlook.com"]
11
+
12
+ spec.summary = %q{Change Numbers to Nepali Names .i.e aanka to akshar ( अंक टु अक्षर )}
13
+ spec.description = %q{ Akshar(अक्षर). This Gem will change Numbers to Nepali Names. example 100.to_akshar = "रुपैयाँ एक सय मात्र ।"}
14
+ spec.homepage = "https://github.com/anupbrt/akshar"
15
+ spec.license = "MIT"
16
+
17
+
18
+
19
+ #spec.add_dependency "activesupport"
20
+
21
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
22
+ # delete this section to allow pushing this gem to any host.
23
+
24
+ spec.files = `git ls-files -z`.split("\x0")
25
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+
32
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "akshar"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/akshar.rb ADDED
@@ -0,0 +1,112 @@
1
+ require "akshar/version"
2
+ require"active_support"
3
+
4
+ module ToAkshar
5
+
6
+ SMALL_NUMBERS = {""=>"", 0=> "शुन्य " , 1=> "एक " , 2=> "दुई " , 3=> "तीन " , 4=> "चार " , 5=> "पाँच " , 6=> "छ " , 7=> "सात " , 8=> "आठ " , 9=> "नौ " , 10=> "दश " , 11=> "एघार " , 12=> "बाह्र " , 13=> "तेह्र " , 14=> "चौध " , 15=> "पन्ध्र " , 16=> "सोह्र " , 17=> "सत्र " , 18=> "अठार " , 19=> "उन्नाइस " , 20=> "विस " , 21=> "एक्काइस " , 22=> "बाइस " , 23=> "तेईस " , 24=> "चौविस " , 25=> "पच्चिस " , 26=> "छब्बिस " , 27=> "सत्ताईस " , 28=> "अठ्ठाईस " , 29=> "उनन्तिस " , 30=> "तिस " , 31=> "एकत्तिस " , 32=> "बत्तिस " , 33=> "तेत्तिस " , 34=> "चौँतिस " , 35=> "पैँतिस " , 36=> " छ्त्तीस " , 37=> "सैंतीस " , 38=> "अठतीस " , 39=> "उनन्चालीस " , 40=> "चालीस " , 41=> "एकचालीस " , 42=> "बयालीस " , 43=> "त्रिचालीस " , 44=> "चौवालीस " , 45=> "पैँतालीस " , 46=> "छयालीस " , 47=> "सच्चालीस " , 48=> "अठचालीस " , 49=> "उनन्चास " , 50=> "पचास " , 51=> "एकाउन्न " , 52=> "बाउन्न " , 53=> "त्रिपन्न " , 54=> "चउन्न " , 55=> "पचपन्न " , 56=> "छपन्न " , 57=> "सन्ताउन्न " , 58=> "अन्ठाउन्न " , 59=> "उनन्साठी " , 60=> "साठी " , 61=> "एकसट्ठी " , 62=> "बयसट्ठी " , 63=> "त्रिसट्ठी " , 64=> "चौंसट्ठी " , 65=> "पैंसट्ठी " , 66=> "छयसट्ठी " , 67=> "सतसट्ठी " , 68=> "अठसट्ठी " , 69=> "उनन्सत्तरी " , 70=> "सत्तरी " , 71=> "एकहत्तर " , 72=> "बहत्तर " , 73=> "त्रिहत्तर " , 74=> "चौहत्तर " , 75=> "पचहत्तर " , 76=> "छयहत्तर " , 77=> "सतहत्तर " , 78=> "अठहत्तर " , 79=> "उनासी " , 80=> "असी " , 81=> "एकासी " , 82=> "बयासी " , 83=> "त्रियासी " , 84=> "चौरासी " , 85=> "पचासी " , 86=> "छयासी " , 87=> "सतासी " , 88=> "अठासी " , 89=> "उनान्नब्बे " , 90=> "नब्बे " , 91=> "एकान्नब्बे " , 92=> "बयानब्बे " , 93=> "त्रियान्नब्बे " , 94=> "चौरान्नब्बे " , 95=> "पन्चानब्बे " , 96=> "छयान्नब्बे " , 97=> "सन्तान्नब्बे " , 98=> "अन्ठान्नब्बे " , 99=> "उनान्सय " , 100=> "एक सय " }
7
+ DIVISIONS = ["","हजार"]
8
+
9
+
10
+ def to_akshar
11
+ #return "रुपैयाँ " + self.to_nepali + " मात्र । "
12
+ if (self.to_nepali == false )
13
+ result = "Impossible Number | Check your Input"
14
+ else
15
+ result = "रुपैयाँ " + self.to_nepali + "मात्र।"
16
+ end
17
+
18
+ result = result.gsub("रुपैयाँमात्र।", 'रुपैयाँ शुन्य मात्र।')
19
+
20
+ #return result.gsub(", पैसा मात्र।", 'मात्र।')
21
+ result = result.gsub(", पैसा मात्र"," मात्र")
22
+ return result.gsub(" , ",", ")
23
+ #result = result.gsub(", पैसा शुन्य", '')
24
+ #return result.gsub("रुपैयाँ मात्र ।", 'रुपैयाँ शुन्य मात्र ।')
25
+ return result
26
+
27
+ end
28
+
29
+ def to_nepali
30
+
31
+
32
+ string = self.to_s.gsub(/\s+/, "")
33
+
34
+ decimalcheck = string.index('.')
35
+ if (decimalcheck != nil )
36
+ #return "Decimal Number Detected" + decimalcheck.to_s
37
+ paisa = string[decimalcheck+1 .. decimalcheck+2 ]
38
+ else
39
+ paisa = ""
40
+ end
41
+ num = self.to_i
42
+ num, sign = check_sign(num)
43
+ return "" if num == 0 && paisa ==""
44
+ return (sign + SMALL_NUMBERS[num])+ ", पैसा " + paisa.to_i.to_nepali if num <= 100
45
+ counter = 0
46
+ result = []
47
+ while num != 0
48
+ if (num > 10000000000000000)
49
+ return false
50
+ elsif ((num / 1000000000000000) >= 1)
51
+ test , remaining = num.divmod(1000000000000000)
52
+ return ((sign + SMALL_NUMBERS[test]) +"पद्म "+ (remaining.to_s+ "."+ paisa).to_nepali )
53
+ elsif ((num / 10000000000000) >= 1)
54
+ test , remaining = num.divmod(10000000000000)
55
+ return ((sign + SMALL_NUMBERS[test]) +"नील "+ (remaining.to_s+"."+paisa).to_nepali )
56
+ elsif ((num / 100000000000) >= 1)
57
+ test , remaining = num.divmod(100000000000)
58
+ return ((sign + SMALL_NUMBERS[test]) +"खर्ब "+ (remaining.to_s+"."+paisa).to_nepali )
59
+ elsif ((num / 1000000000) >= 1)
60
+ test , remaining = num.divmod(1000000000)
61
+ return ((sign + SMALL_NUMBERS[test]) +"अर्ब "+ (remaining.to_s+"."+paisa).to_nepali )
62
+ elsif ((num / 10000000) >= 1)
63
+ test , remaining = num.divmod(10000000)
64
+ return ((sign + SMALL_NUMBERS[test]) +"करोड "+ (remaining.to_s+"."+paisa).to_nepali )
65
+ elsif ((num / 100000) >= 1)
66
+ test , remaining = num.divmod(100000)
67
+ return ((sign + SMALL_NUMBERS[test]) +"लाख "+ (remaining.to_s+"."+paisa).to_nepali )
68
+
69
+ end
70
+
71
+ num, remaining = num.divmod(1000)
72
+
73
+ temp_result = result_below_one_thousand(remaining, counter)
74
+ result << temp_result + "" + DIVISIONS[counter] + " " if temp_result != ''
75
+ counter += 1
76
+ end
77
+ return sign + result.reverse.join("").rstrip + ", पैसा " + paisa.to_i.to_nepali
78
+ end
79
+
80
+
81
+
82
+ def result_below_one_thousand(num, counter)
83
+ hundred, remaining = num.divmod(100)
84
+ #return SMALL_NUMBERS[hundred] + " सय " + SMALL_NUMBERS[remaining] if hundred != 0 && remaining != 0 && counter != 0
85
+ return SMALL_NUMBERS[hundred] + "सय " + SMALL_NUMBERS[remaining] if hundred != 0 && remaining != 0
86
+ return SMALL_NUMBERS[remaining] if hundred == 0 && remaining != 0
87
+ return SMALL_NUMBERS[hundred] + "सय " if hundred != 0 && remaining == 0
88
+ return ''
89
+ end
90
+
91
+ def check_sign(num)
92
+ return num < 0 ? ([num.abs, 'ॠणात्मक ']) : ([num, ''])
93
+ end
94
+
95
+ end
96
+
97
+
98
+ class Fixnum
99
+ include ToAkshar
100
+ end
101
+
102
+ class Float
103
+ include ToAkshar
104
+ end
105
+
106
+ class String
107
+ include ToAkshar
108
+ end
109
+
110
+ class Bignum
111
+ include ToAkshar
112
+ end
@@ -0,0 +1,3 @@
1
+ module Akshar
2
+ VERSION = "0.1.3"
3
+ end
Binary file
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Akshar do
4
+ it 'has a version number' do
5
+ expect(Akshar::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'akshar'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akshar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anup Neupane
@@ -9,15 +9,62 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-07-29 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
13
41
  description: ' Akshar(अक्षर). This Gem will change Numbers to Nepali Names. example
14
42
  100.to_akshar = "रुपैयाँ एक सय मात्र ।"'
15
43
  email:
16
44
  - anupbrt@outlook.com
17
- executables: []
45
+ executables:
46
+ - console
47
+ - setup
18
48
  extensions: []
19
49
  extra_rdoc_files: []
20
- files: []
50
+ files:
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - akshar-0.0.1.gem
58
+ - akshar-0.0.2.gem
59
+ - akshar-0.0.3.gem
60
+ - akshar.gemspec
61
+ - bin/console
62
+ - bin/setup
63
+ - lib/akshar.rb
64
+ - lib/akshar/version.rb
65
+ - pkg/akshar-0.0.1.gem
66
+ - spec/akshar_spec.rb
67
+ - spec/spec_helper.rb
21
68
  homepage: https://github.com/anupbrt/akshar
22
69
  licenses:
23
70
  - MIT
@@ -42,4 +89,6 @@ rubygems_version: 2.4.6
42
89
  signing_key:
43
90
  specification_version: 4
44
91
  summary: Change Numbers to Nepali Names .i.e aanka to akshar ( अंक टु अक्षर )
45
- test_files: []
92
+ test_files:
93
+ - spec/akshar_spec.rb
94
+ - spec/spec_helper.rb