parayaz 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/parayaz/version.rb +1 -1
- data/lib/parayaz.rb +68 -21
- data/parayaz.gemspec +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa269eaa8b3e3d602997d6f88bc06cbe62f5dc33
|
4
|
+
data.tar.gz: 2d9fc903a199bcab36e1337fd738ca0a3627ef1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9280f4d07cdb5f95e9f465e9307506d016dc1d32941d52317f47d11273511897795545ce288f63dde5c59e3b608a0c01fde987eca1a9dc76c8883426d4410216
|
7
|
+
data.tar.gz: ea61fe601be6dfe71d0b46ba6a639aec1ad16048b2cd4f2e0747165acb61710dd8078f3e5e5be6f1b1b3a9873c035393cd8658941b43a09a824e52390efe0552
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
2
|
#### [Current]
|
3
|
+
* [a347fd7](../../commit/a347fd7) - __(Ahmet Sezgin Duran)__ Revert back to original file
|
4
|
+
|
5
|
+
#### 1.0.2
|
6
|
+
* [4e260af](../../commit/4e260af) - __(Ahmet Sezgin Duran)__ Bump version 1.0.2
|
3
7
|
* [e14b059](../../commit/e14b059) - __(Ahmet Sezgin Duran)__ [#1](../../issues/1) Fix negative number error
|
4
8
|
|
5
9
|
#### 1.0.1
|
data/Gemfile.lock
CHANGED
data/lib/parayaz/version.rb
CHANGED
data/lib/parayaz.rb
CHANGED
@@ -1,24 +1,71 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
1
|
require 'parayaz/version'
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
3
|
+
module Parayaz
|
4
|
+
def parayaz
|
5
|
+
number = self
|
6
|
+
minus = number < 0
|
7
|
+
|
8
|
+
number *= -1 if minus
|
9
|
+
|
10
|
+
price, cents = number.to_s.split('.')
|
11
|
+
|
12
|
+
text = convert_to_text(price) + 'TL'
|
13
|
+
if cents && cents.to_i > 0
|
14
|
+
if cents.size == 1
|
15
|
+
cents = (cents.to_i * 10).to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
if cents.size > 2
|
19
|
+
cents = cents[0..1]
|
20
|
+
end
|
21
|
+
|
22
|
+
text += ',' + convert_to_text(cents) + 'kr'
|
23
|
+
end
|
24
|
+
|
25
|
+
(minus ? 'eksi' : '') + text + '.'
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def say_1_digit_text(n)
|
30
|
+
one_digits_text = ['', 'bir', 'iki', 'üç', 'dört', 'beş', 'altı', 'yedi', 'sekiz', 'dokuz']
|
31
|
+
one_digits_text[n]
|
32
|
+
end
|
33
|
+
|
34
|
+
def say_2_digit_text(n)
|
35
|
+
two_digits_text = ['', 'on', 'yirmi', 'otuz', 'kırk', 'elli', 'altmış', 'yetmiş', 'seksen', 'doksan']
|
36
|
+
two_digits_text[n[0]] + say_1_digit_text(n[1])
|
37
|
+
end
|
38
|
+
|
39
|
+
def say_3_digit_text(n)
|
40
|
+
one = n[0] == 1 ? 'yüz' : say_1_digit_text(n[0])
|
41
|
+
one += 'yüz' unless n[0] == 1 || n[0] == 0
|
42
|
+
n.delete_at(0)
|
43
|
+
one + say_2_digit_text(n)
|
44
|
+
end
|
45
|
+
|
46
|
+
def convert_to_text(number)
|
47
|
+
number = number.to_i
|
48
|
+
lots = ['', 'bin', 'milyon', 'milyar', 'trilyon', 'katrilyon', 'kentilyon', 'seksilyon', 'septilyon']
|
49
|
+
|
50
|
+
text = ''
|
51
|
+
|
52
|
+
i = 0
|
53
|
+
while !number.zero?
|
54
|
+
number, r = number.divmod(1000)
|
55
|
+
size = r.to_s.split('').map(&:to_i).size
|
56
|
+
new_text = r == 1 && i == 1 ? "" : eval("say_#{size}_digit_text(#{size == 1 ? r : r.to_s.split('').map(&:to_i)})")
|
57
|
+
|
58
|
+
unless r == 0
|
59
|
+
new_text += lots[i]
|
60
|
+
end
|
61
|
+
|
62
|
+
text = new_text + text
|
63
|
+
i += 1
|
64
|
+
end
|
65
|
+
text
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Numeric
|
70
|
+
include Parayaz
|
24
71
|
end
|
data/parayaz.gemspec
CHANGED
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'parayaz/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'parayaz'
|
8
8
|
spec.version = Parayaz::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['lab2023']
|
10
|
+
spec.email = ['info@lab2023.com']
|
11
11
|
spec.summary = %q{Turkish number to text money}
|
12
12
|
spec.description = %q{Turkish number to text money}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/lab2023/parayaz'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
end
|