akshar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b0d8240403e53feee2ff6e7b88ec5bba0200ac12
4
+ data.tar.gz: a50a1386ebbbe7ce9f11110d74ea8b2842f936f2
5
+ SHA512:
6
+ metadata.gz: f7e65c2da196f7aca8ed6430d0c2808b710163c602d33bcfe9e99731ef4e5eafc599c62ca5c07c93e002ddbeffde1b89de32add65b833bb0eb12390b28e33e00
7
+ data.tar.gz: e608c03740dc9afea3a7fc3bd91ce10d31c111259bc8c664da8a8cf27b61358ccbee2fa61c4c209528ee722bc3c7ead61df17b6ec2b2d74e428cdbf6ba77dc6f
@@ -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.1)
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,36 @@
1
+ # Akshar
2
+
3
+ Convert Numbers to Nepali Words( actually...Nepali words for Money ).
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'akshar'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install akshar
21
+
22
+ ## Usage
23
+
24
+ TODO: to_akshar
25
+
26
+ ## Development
27
+
28
+
29
+
30
+ ## Contributing
31
+
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
36
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
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{This Gem will change Numbers to Nepali Names. example 100.akshar = "ek saya"}
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,91 @@
1
+ require "akshar/version"
2
+
3
+ module ToAkshar
4
+
5
+ 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=>"एक सय"}
6
+ DIVISIONS = ["","हजार"]
7
+
8
+
9
+ def to_akshar
10
+ return "रुपैयाँ " + self.to_nepali + " मात्र । "
11
+ end
12
+
13
+ def to_nepali
14
+
15
+
16
+ string = self.to_s.gsub(/\s+/, "")
17
+
18
+ decimalcheck = string.index('.')
19
+ if (decimalcheck != nil )
20
+ #return "Decimal Number Detected" + decimalcheck.to_s
21
+ paisa = string[decimalcheck+1 .. decimalcheck+2 ]
22
+ else
23
+ paisa = "0"
24
+ end
25
+ num = self.to_i
26
+ num, sign = check_sign(num)
27
+ return (sign + SMALL_NUMBERS[num]) if num <= 100
28
+ counter = 0
29
+ result = []
30
+ while num != 0
31
+ if (num > 10000000000000000)
32
+ return ("Very BIG NUMBER")
33
+ elsif ((num / 1000000000000000) >= 1)
34
+ test , remaining = num.divmod(1000000000000000)
35
+ return ((sign + SMALL_NUMBERS[test]) +" पद्म "+ (remaining.to_s+ "."+ paisa).to_nepali )
36
+ elsif ((num / 10000000000000) >= 1)
37
+ test , remaining = num.divmod(10000000000000)
38
+ return ((sign + SMALL_NUMBERS[test]) +" नील "+ (remaining.to_s+"."+paisa).to_nepali )
39
+ elsif ((num / 100000000000) >= 1)
40
+ test , remaining = num.divmod(100000000000)
41
+ return ((sign + SMALL_NUMBERS[test]) +" खर्ब "+ (remaining.to_s+"."+paisa).to_nepali )
42
+ elsif ((num / 1000000000) >= 1)
43
+ test , remaining = num.divmod(1000000000)
44
+ return ((sign + SMALL_NUMBERS[test]) +" अर्ब "+ (remaining.to_s+"."+paisa).to_nepali )
45
+ elsif ((num / 10000000) >= 1)
46
+ test , remaining = num.divmod(10000000)
47
+ return ((sign + SMALL_NUMBERS[test]) +" करोड "+ (remaining.to_s+"."+paisa).to_nepali )
48
+ elsif ((num / 100000) >= 1)
49
+ test , remaining = num.divmod(100000)
50
+ return ((sign + SMALL_NUMBERS[test]) +" लाख "+ (remaining.to_s+"."+paisa).to_nepali )
51
+
52
+ end
53
+
54
+ num, remaining = num.divmod(1000)
55
+
56
+ temp_result = result_below_one_thousand(remaining, counter)
57
+ result << temp_result + " " + DIVISIONS[counter] + "" if temp_result != ''
58
+ counter += 1
59
+ end
60
+ return sign + result.reverse.join(" ").rstrip + ", पैसा " + paisa.to_i.to_nepali
61
+ end
62
+
63
+
64
+
65
+ def result_below_one_thousand(num, counter)
66
+ hundred, remaining = num.divmod(100)
67
+ #return SMALL_NUMBERS[hundred] + " सय " + SMALL_NUMBERS[remaining] if hundred != 0 && remaining != 0 && counter != 0
68
+ return SMALL_NUMBERS[hundred] + " सय " + SMALL_NUMBERS[remaining] if hundred != 0 && remaining != 0
69
+ return SMALL_NUMBERS[remaining] if hundred == 0 && remaining != 0
70
+ return SMALL_NUMBERS[hundred] + " सय " if hundred != 0 && remaining == 0
71
+ return ''
72
+ end
73
+
74
+ def check_sign(num)
75
+ return num < 0 ? ([num.abs, 'ॠणात्मक ']) : ([num, ''])
76
+ end
77
+
78
+ end
79
+
80
+
81
+ class Fixnum
82
+ include ToAkshar
83
+ end
84
+
85
+ class Float
86
+ include ToAkshar
87
+ end
88
+
89
+ class String
90
+ include ToAkshar
91
+ end
@@ -0,0 +1,3 @@
1
+ module Akshar
2
+ VERSION = "0.0.1"
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 ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: akshar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Anup Neupane
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-14 00:00:00.000000000 Z
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'
41
+ description: This Gem will change Numbers to Nepali Names. example 100.akshar = "ek
42
+ saya"
43
+ email:
44
+ - anupbrt@outlook.com
45
+ executables:
46
+ - console
47
+ - setup
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - akshar.gemspec
58
+ - bin/console
59
+ - bin/setup
60
+ - lib/akshar.rb
61
+ - lib/akshar/version.rb
62
+ - pkg/akshar-0.0.1.gem
63
+ - spec/akshar_spec.rb
64
+ - spec/spec_helper.rb
65
+ homepage: https://github.com/anupbrt/akshar
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.4.8
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Change Numbers to Nepali Names .i.e aanka to akshar
89
+ test_files:
90
+ - spec/akshar_spec.rb
91
+ - spec/spec_helper.rb