tbpgr_utils 0.0.68 → 0.0.69
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -0
- data/lib/open_classes/numeric.rb +1 -0
- data/lib/open_classes/numeric/dozen.rb +19 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/open_classes/numeric/dice_back_spec.rb +79 -79
- data/spec/open_classes/numeric/dozen_spec.rb +55 -0
- metadata +15 -12
data/README.md
CHANGED
@@ -85,6 +85,7 @@ Or install it yourself as:
|
|
85
85
|
|[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes |
|
86
86
|
|[TbpgrUtils Module.alias_methods](#modulealias_methods) |create alias methods |
|
87
87
|
|[TbpgrUtils Numeric#dice_back](#numericdice_back) |return dice back number |
|
88
|
+
|[TbpgrUtils Numeric#dozen](#numericdozen) |get dozen number |
|
88
89
|
|[TbpgrUtils Object#any_of?](#objectany_of) |if self match any one of items, return true |
|
89
90
|
|[TbpgrUtils Object#boolean?](#objectboolean) |data type check for boolean |
|
90
91
|
|[TbpgrUtils Object#guard](#objectguard) |data type check for guard |
|
@@ -2061,6 +2062,19 @@ other case
|
|
2061
2062
|
|
2062
2063
|
[back to list](#list)
|
2063
2064
|
|
2065
|
+
### Numeric#dozen
|
2066
|
+
0,1,2 case
|
2067
|
+
|
2068
|
+
~~~ruby
|
2069
|
+
require 'tbpgr_utils'
|
2070
|
+
|
2071
|
+
0.dozen # => return 0
|
2072
|
+
1.dozen # => return 12
|
2073
|
+
2.dozen # => return 24
|
2074
|
+
~~~
|
2075
|
+
|
2076
|
+
[back to list](#list)
|
2077
|
+
|
2064
2078
|
### Object#any_of?
|
2065
2079
|
~~~ruby
|
2066
2080
|
require 'tbpgr_utils'
|
@@ -2550,6 +2564,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
2550
2564
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
2551
2565
|
|
2552
2566
|
## History
|
2567
|
+
* version 0.0.69 : add Numeric#dozen
|
2553
2568
|
* version 0.0.68 : add Numeric#dice_back
|
2554
2569
|
* version 0.0.67 : add EvalHelper#attr_accessor_init_code
|
2555
2570
|
* version 0.0.66 : add EvalHelper#each_with_index_do_code
|
data/lib/open_classes/numeric.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Numeric
|
4
|
+
class Numeric
|
5
|
+
# get dozen number
|
6
|
+
#
|
7
|
+
# ==== Examples
|
8
|
+
#
|
9
|
+
# 0,1,2 case
|
10
|
+
#
|
11
|
+
# 0.dozen # => return 0
|
12
|
+
# 1.dozen # => return 12
|
13
|
+
# 2.dozen # => return 24
|
14
|
+
#
|
15
|
+
def dozen
|
16
|
+
return 0 if self == 0
|
17
|
+
self * 12
|
18
|
+
end
|
19
|
+
end
|
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -1,79 +1,79 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'tbpgr_utils'
|
4
|
-
|
5
|
-
describe Numeric do
|
6
|
-
context :dice_back do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: '1 case',
|
11
|
-
input: 1,
|
12
|
-
expected: 6,
|
13
|
-
},
|
14
|
-
{
|
15
|
-
case_no: 2,
|
16
|
-
case_title: '2 case',
|
17
|
-
input: 2,
|
18
|
-
expected: 5,
|
19
|
-
},
|
20
|
-
{
|
21
|
-
case_no: 3,
|
22
|
-
case_title: '3 case',
|
23
|
-
input: 3,
|
24
|
-
expected: 4,
|
25
|
-
},
|
26
|
-
{
|
27
|
-
case_no: 4,
|
28
|
-
case_title: '4 case',
|
29
|
-
input: 4,
|
30
|
-
expected: 3,
|
31
|
-
},
|
32
|
-
{
|
33
|
-
case_no: 5,
|
34
|
-
case_title: '5 case',
|
35
|
-
input: 5,
|
36
|
-
expected: 2,
|
37
|
-
},
|
38
|
-
{
|
39
|
-
case_no: 6,
|
40
|
-
case_title: '6 case',
|
41
|
-
input: 6,
|
42
|
-
expected: 1,
|
43
|
-
},
|
44
|
-
{
|
45
|
-
case_no: 7,
|
46
|
-
case_title: '7 case',
|
47
|
-
input: 7,
|
48
|
-
expected: 7,
|
49
|
-
},
|
50
|
-
]
|
51
|
-
|
52
|
-
cases.each do |c|
|
53
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
54
|
-
begin
|
55
|
-
case_before c
|
56
|
-
|
57
|
-
# -- given --
|
58
|
-
# nothing
|
59
|
-
|
60
|
-
# -- when --
|
61
|
-
actual = c[:input].dice_back
|
62
|
-
|
63
|
-
# -- then --
|
64
|
-
expect(actual).to eq(c[:expected])
|
65
|
-
ensure
|
66
|
-
case_after c
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def case_before(c)
|
71
|
-
# implement each case before
|
72
|
-
end
|
73
|
-
|
74
|
-
def case_after(c)
|
75
|
-
# implement each case after
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Numeric do
|
6
|
+
context :dice_back do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: '1 case',
|
11
|
+
input: 1,
|
12
|
+
expected: 6,
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: '2 case',
|
17
|
+
input: 2,
|
18
|
+
expected: 5,
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: '3 case',
|
23
|
+
input: 3,
|
24
|
+
expected: 4,
|
25
|
+
},
|
26
|
+
{
|
27
|
+
case_no: 4,
|
28
|
+
case_title: '4 case',
|
29
|
+
input: 4,
|
30
|
+
expected: 3,
|
31
|
+
},
|
32
|
+
{
|
33
|
+
case_no: 5,
|
34
|
+
case_title: '5 case',
|
35
|
+
input: 5,
|
36
|
+
expected: 2,
|
37
|
+
},
|
38
|
+
{
|
39
|
+
case_no: 6,
|
40
|
+
case_title: '6 case',
|
41
|
+
input: 6,
|
42
|
+
expected: 1,
|
43
|
+
},
|
44
|
+
{
|
45
|
+
case_no: 7,
|
46
|
+
case_title: '7 case',
|
47
|
+
input: 7,
|
48
|
+
expected: 7,
|
49
|
+
},
|
50
|
+
]
|
51
|
+
|
52
|
+
cases.each do |c|
|
53
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
54
|
+
begin
|
55
|
+
case_before c
|
56
|
+
|
57
|
+
# -- given --
|
58
|
+
# nothing
|
59
|
+
|
60
|
+
# -- when --
|
61
|
+
actual = c[:input].dice_back
|
62
|
+
|
63
|
+
# -- then --
|
64
|
+
expect(actual).to eq(c[:expected])
|
65
|
+
ensure
|
66
|
+
case_after c
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def case_before(c)
|
71
|
+
# implement each case before
|
72
|
+
end
|
73
|
+
|
74
|
+
def case_after(c)
|
75
|
+
# implement each case after
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Numeric do
|
6
|
+
context :dozen do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: '1 case',
|
11
|
+
input: 1,
|
12
|
+
expected: 12,
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: '2 case',
|
17
|
+
input: 2,
|
18
|
+
expected: 24,
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: '0 case',
|
23
|
+
input: 0,
|
24
|
+
expected: 0,
|
25
|
+
},
|
26
|
+
]
|
27
|
+
|
28
|
+
cases.each do |c|
|
29
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
30
|
+
begin
|
31
|
+
case_before c
|
32
|
+
|
33
|
+
# -- given --
|
34
|
+
# nothing
|
35
|
+
|
36
|
+
# -- when --
|
37
|
+
actual = c[:input].dozen
|
38
|
+
|
39
|
+
# -- then --
|
40
|
+
expect(actual).to eq(c[:expected])
|
41
|
+
ensure
|
42
|
+
case_after c
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def case_before(c)
|
47
|
+
# implement each case before
|
48
|
+
end
|
49
|
+
|
50
|
+
def case_after(c)
|
51
|
+
# implement each case after
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbpgr_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.69
|
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: 2014-03-
|
12
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &26980260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 4.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *26980260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &26979972 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *26979972
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &26979744 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *26979744
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &26979420 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.14.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *26979420
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &26979120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.8.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *26979120
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/open_classes/module.rb
|
140
140
|
- lib/open_classes/numeric.rb
|
141
141
|
- lib/open_classes/numeric/dice_back.rb
|
142
|
+
- lib/open_classes/numeric/dozen.rb
|
142
143
|
- lib/open_classes/object.rb
|
143
144
|
- lib/open_classes/object/any_of.rb
|
144
145
|
- lib/open_classes/object/boolean.rb
|
@@ -216,6 +217,7 @@ files:
|
|
216
217
|
- spec/open_classes/kernel/puts_eval_spec.rb
|
217
218
|
- spec/open_classes/module_spec.rb
|
218
219
|
- spec/open_classes/numeric/dice_back_spec.rb
|
220
|
+
- spec/open_classes/numeric/dozen_spec.rb
|
219
221
|
- spec/open_classes/object/any_of_spec.rb
|
220
222
|
- spec/open_classes/object/boolean_spec.rb
|
221
223
|
- spec/open_classes/object/guard_spec.rb
|
@@ -315,6 +317,7 @@ test_files:
|
|
315
317
|
- spec/open_classes/kernel/puts_eval_spec.rb
|
316
318
|
- spec/open_classes/module_spec.rb
|
317
319
|
- spec/open_classes/numeric/dice_back_spec.rb
|
320
|
+
- spec/open_classes/numeric/dozen_spec.rb
|
318
321
|
- spec/open_classes/object/any_of_spec.rb
|
319
322
|
- spec/open_classes/object/boolean_spec.rb
|
320
323
|
- spec/open_classes/object/guard_spec.rb
|