core_extend 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/core_extend.gemspec +32 -0
- data/lib/core_extend.rb +7 -0
- data/lib/core_extend/float.rb +35 -0
- data/lib/core_extend/version.rb +3 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7affb16c4c306cbc66c58037215d1bcdf1ef332b
|
4
|
+
data.tar.gz: c6eb4626d0124eb516fc85eb0d2bfdc0bc934e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 257b654f6cb1724d87380e78611ebfb1b7c4e8a7305a0a30cce1616f2f37b1423a17288bf36d445eb771bc8ec3315ab668497c5f6ae933aa9baf141e0ad3bfc5
|
7
|
+
data.tar.gz: 6b2365dd77d4d3261e3c9bfe6e01b70cb91f6695b392c26fc7c2888457f8f5b8b13cb52d4e35a5e1ea9ae28e788897dcb2135bafdfda1dad5870dba20b3f1dda
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# CoreExtend
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/core_extend`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'core_extend'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install core_extend
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/core_extend/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "core_extend"
|
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
data/core_extend.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 'core_extend/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "core_extend"
|
8
|
+
spec.version = CoreExtend::VERSION
|
9
|
+
spec.authors = ["saxer"]
|
10
|
+
spec.email = ["15201280641@qq.com"]
|
11
|
+
spec.licenses = ["MIT"]
|
12
|
+
|
13
|
+
spec.summary = %q{Ruby core extensions}
|
14
|
+
spec.description = %q{Ruby core object extensions}
|
15
|
+
spec.homepage = "https://github.com/mumaoxi/core_extend"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
end
|
data/lib/core_extend.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Float
|
2
|
+
|
3
|
+
#保留小数点位数
|
4
|
+
def decimal_point(point=2)
|
5
|
+
sprintf("%0.#{point}f", self).to_f
|
6
|
+
end
|
7
|
+
|
8
|
+
#显示成钱数
|
9
|
+
#===Parameters
|
10
|
+
# +type+ enum 'num','text'
|
11
|
+
#===Returns
|
12
|
+
# +string+
|
13
|
+
def to_money(type='num',point=2)
|
14
|
+
str = decimal_point(point).to_s
|
15
|
+
int_str = str.split('.')[0]
|
16
|
+
point_str = str.split('.')[1]
|
17
|
+
|
18
|
+
if type=='text'
|
19
|
+
return "#{int_str}.#{point_str}" if int_str.to_i<10000
|
20
|
+
|
21
|
+
return "#{(int_str.to_i/10000.0).decimal_point(point)}万" if int_str.to_i<100000000
|
22
|
+
|
23
|
+
return "#{(int_str.to_i/100000000.0).decimal_point(point)}亿"
|
24
|
+
end
|
25
|
+
|
26
|
+
return "#{int_str}.#{point_str}" if int_str.length<3
|
27
|
+
index = -4
|
28
|
+
while index.abs < int_str.length+1
|
29
|
+
int_str.insert(index, ',')
|
30
|
+
index -=4
|
31
|
+
end
|
32
|
+
"#{int_str}.#{point_str}"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core_extend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,8 +46,19 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
49
52
|
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- core_extend.gemspec
|
58
|
+
- lib/core_extend.rb
|
50
59
|
- lib/core_extend/array.rb
|
60
|
+
- lib/core_extend/float.rb
|
61
|
+
- lib/core_extend/version.rb
|
51
62
|
homepage: https://github.com/mumaoxi/core_extend
|
52
63
|
licenses:
|
53
64
|
- MIT
|