numformat_lili 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/numformat.rb +13 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f1aa6895c5cb19114be6c6c4774f54a5f9f0612
4
+ data.tar.gz: 4278723c8a175441f4a36036ae40e554d1a62a0b
5
+ SHA512:
6
+ metadata.gz: e22b87eabdc91da77866f44c3bdf89ad26951eaacb1126e2851761ad2b9d3e413aca2c176f7068b9860239fabdae2e5b4fd851b09f7be2fe696226bd04671f81
7
+ data.tar.gz: 3da68b9d0538b7c02f62483a8f7f3471d9bb7e720423f338e527c071860d78eb5e2ca168081e65ccb9eb998e1b2fdce275e388a55fbc4306371a043c36a9f6fa
data/lib/numformat.rb ADDED
@@ -0,0 +1,13 @@
1
+ class NumberFormat
2
+ def format(number)
3
+ if number < 1000
4
+ number.to_s
5
+ elsif number < 1_000_000
6
+ n = (number / 1000.to_f).round(1)
7
+ "#{n}K"
8
+ else
9
+ n = (number / 1_000_000-to_f).round(1)
10
+ "#{n}M"
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: numformat_lili
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Liliana Restrepo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple gem to convert number to notation
14
+ email: lilianarestrepot@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/numformat.rb
20
+ homepage: https://github.com/LilianaRestrepoTorres/numformat
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A simple gem to convert number to notation
44
+ test_files: []