gyomu_ruby 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +4 -0
- data/lib/gyomu_ruby.rb +1 -0
- data/lib/gyomu_ruby/core_ext/numeric.rb +6 -0
- data/lib/gyomu_ruby/core_ext/numeric/round.rb +15 -0
- data/lib/gyomu_ruby/core_ext/time.rb +1 -1
- data/lib/gyomu_ruby/core_ext/time/biz_year.rb +1 -1
- data/lib/gyomu_ruby/version.rb +1 -1
- data/spec/core_ext/numeric_spec.rb +18 -0
- metadata +12 -12
- data/lib/gyomu_ruby/core_ext/integer.rb +0 -1
- data/lib/gyomu_ruby/core_ext/integer/round.rb +0 -9
- data/spec/core_ext/integer_spec.rb +0 -18
data/HISTORY.md
CHANGED
data/lib/gyomu_ruby.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module GyomuRuby
|
2
|
+
module CoreExt
|
3
|
+
module Numeric
|
4
|
+
module Round
|
5
|
+
def roundup(offset)
|
6
|
+
((self + offset) * Rational(1, offset)).ceil * offset - offset
|
7
|
+
end
|
8
|
+
|
9
|
+
def rounddown(offset)
|
10
|
+
(self * Rational(1, offset)).floor * offset
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/gyomu_ruby/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gyomu_ruby/core_ext/numeric'
|
3
|
+
|
4
|
+
describe Numeric, 'gyomu_ruby extentions' do
|
5
|
+
describe '#roundup' do
|
6
|
+
it { 101.roundup(50).should == 150 }
|
7
|
+
it { 151.roundup(50).should == 200 }
|
8
|
+
it { 123.roundup(3).should == 123 }
|
9
|
+
it { 10.1.roundup(2).should == 12 }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#rounddown' do
|
13
|
+
it { 101.rounddown(50).should == 100 }
|
14
|
+
it { 151.rounddown(50).should == 150 }
|
15
|
+
it { 123.rounddown(3).should == 123 }
|
16
|
+
it { 10.1.rounddown(2).should == 10 }
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gyomu_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70316203047040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70316203047040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: aws-s3
|
27
|
-
requirement: &
|
27
|
+
requirement: &70316203044320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70316203044320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70316203032080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70316203032080
|
47
47
|
description: GyomuRuby
|
48
48
|
email:
|
49
49
|
- rubyagile@qwik.tky.esm.co.jp
|
@@ -59,8 +59,8 @@ files:
|
|
59
59
|
- gyomu_ruby.gemspec
|
60
60
|
- lib/gyomu_ruby.rb
|
61
61
|
- lib/gyomu_ruby/amazon_web_service/file_bucket.rb
|
62
|
-
- lib/gyomu_ruby/core_ext/
|
63
|
-
- lib/gyomu_ruby/core_ext/
|
62
|
+
- lib/gyomu_ruby/core_ext/numeric.rb
|
63
|
+
- lib/gyomu_ruby/core_ext/numeric/round.rb
|
64
64
|
- lib/gyomu_ruby/core_ext/time.rb
|
65
65
|
- lib/gyomu_ruby/core_ext/time/biz_year.rb
|
66
66
|
- lib/gyomu_ruby/forgery/dictionaries/ja_female_first_names
|
@@ -74,7 +74,7 @@ files:
|
|
74
74
|
- lib/gyomu_ruby/version.rb
|
75
75
|
- masters/ext_tel_numbers.csv
|
76
76
|
- masters/prefectures.csv
|
77
|
-
- spec/core_ext/
|
77
|
+
- spec/core_ext/numeric_spec.rb
|
78
78
|
- spec/core_ext/time_spec.rb
|
79
79
|
- spec/spec_helper.rb
|
80
80
|
homepage: http://www.esm.co.jp/
|
@@ -102,7 +102,7 @@ signing_key:
|
|
102
102
|
specification_version: 3
|
103
103
|
summary: GyomuRuby
|
104
104
|
test_files:
|
105
|
-
- spec/core_ext/
|
105
|
+
- spec/core_ext/numeric_spec.rb
|
106
106
|
- spec/core_ext/time_spec.rb
|
107
107
|
- spec/spec_helper.rb
|
108
108
|
has_rdoc:
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'gyomu_ruby/core_ext/integer/round'
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'gyomu_ruby/core_ext/integer'
|
3
|
-
|
4
|
-
describe Integer, 'gyomu_ruby extentions' do
|
5
|
-
describe '#ceil' do
|
6
|
-
it { 101.ceil(50).should == 150 }
|
7
|
-
it { 151.ceil(50).should == 200 }
|
8
|
-
it { 121.ceil(3).should == 123 }
|
9
|
-
it { 123.ceil(3).should == 123 }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#floor' do
|
13
|
-
it { 101.floor(50).should == 100 }
|
14
|
-
it { 151.floor(50).should == 150 }
|
15
|
-
it { 121.floor(3).should == 120 }
|
16
|
-
it { 123.floor(3).should == 123 }
|
17
|
-
end
|
18
|
-
end
|