tbpgr_utils 0.0.98 → 0.0.99

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.
data/README.md CHANGED
@@ -104,6 +104,7 @@ Or install it yourself as:
104
104
  |[TbpgrUtils Numeric to_digit_table](#numeric-to_digit_table) |digit table |
105
105
  |[TbpgrUtils Numeric to_hex_html_table](#numeric-to_hex_html_table) |hex html table |
106
106
  |[TbpgrUtils Numeric to_hex_table](#numeric-to_hex_table) |hex table |
107
+ |[TbpgrUtils Numeric to_oct_html_table](#numeric-to_oct_html_table) |oct html table |
107
108
  |[TbpgrUtils Numeric to_oct_table](#numeric-to_oct_table) |oct table |
108
109
  |[TbpgrUtils Object#any_of?](#objectany_of) |if self match any one of items, return true |
109
110
  |[TbpgrUtils Object#boolean?](#objectboolean) |data type check for boolean |
@@ -2521,6 +2522,33 @@ result
2521
2522
 
2522
2523
  [back to list](#list)
2523
2524
 
2525
+ ### Numeric to_oct_html_table
2526
+ 65535 to 65536 case
2527
+ ~~~ruby
2528
+ require 'tbpgr_utils'
2529
+ Numeric.to_oct_html_table(65535, 65536)
2530
+ ~~~
2531
+
2532
+ result
2533
+ ~~~
2534
+ <table>
2535
+ <tr>
2536
+ <th>10digit</th>
2537
+ <th>8digit</th>
2538
+ </tr>
2539
+ <tr>
2540
+ <td>65535</td>
2541
+ <td>177777</td>
2542
+ </tr>
2543
+ <tr>
2544
+ <td>65536</td>
2545
+ <td>200000</td>
2546
+ </tr>
2547
+ </table>
2548
+ ~~~
2549
+
2550
+ [back to list](#list)
2551
+
2524
2552
  ### Numeric to_oct_table
2525
2553
  65535 to 65536 case
2526
2554
  ~~~ruby
@@ -3196,6 +3224,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3196
3224
  https://github.com/tbpgr/tbpgr_utils_snippets
3197
3225
 
3198
3226
  ## History
3227
+ * version 0.0.99 : add Numeric.to_oct_html_table
3199
3228
  * version 0.0.98 : add Numeric.to_hex_html_table
3200
3229
  * version 0.0.97 : add Numeric.to_digit_html_table
3201
3230
  * version 0.0.96 : add Numeric.to_binary_html_table
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ # Numeric
4
+ class Numeric
5
+ # return is oct html table
6
+ #
7
+ # ==== Examples
8
+ #
9
+ # 65535 to 65536 case
10
+ #
11
+ # Numeric.to_oct_html_table(65535, 65536)
12
+ #
13
+ # result
14
+ #
15
+ # <table>
16
+ # <tr>
17
+ # <th>10digit</th>
18
+ # <th>8digit</th>
19
+ # </tr>
20
+ # <tr>
21
+ # <td>65535</td>
22
+ # <td>177777</td>
23
+ # </tr>
24
+ # <tr>
25
+ # <td>65536</td>
26
+ # <td>200000</td>
27
+ # </tr>
28
+ # </table>
29
+ #
30
+ def self.to_oct_html_table(from = 1, to = 10)
31
+ ret = []
32
+ size = to.to_s(8).size
33
+ ret << "<table>\n <tr>\n <th>10digit</th>\n <th>8digit</th>\n </tr>"
34
+ (from..to).each { |i|ret << " <tr>\n <td>#{i}</td>\n <td>#{i.to_s(8)}</td>\n </tr>" }
35
+ ret.join("\n") + "\n</table>\n"
36
+ end
37
+ end
@@ -8,4 +8,5 @@ require 'open_classes/numeric/to_digit_html_table'
8
8
  require 'open_classes/numeric/to_digit_table'
9
9
  require 'open_classes/numeric/to_hex_html_table'
10
10
  require 'open_classes/numeric/to_hex_table'
11
+ require 'open_classes/numeric/to_oct_html_table'
11
12
  require 'open_classes/numeric/to_oct_table'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.98'
5
+ VERSION = '0.0.99'
6
6
  end
@@ -11,7 +11,7 @@ describe Familyable::Family do
11
11
  persons: [
12
12
  a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
13
13
  b = Familyable::Person.new(id: 2, parent_ids: []),
14
- c = Familyable::Person.new(id: 3, parent_ids: [4],),
14
+ c = Familyable::Person.new(id: 3, parent_ids: [4], ),
15
15
  d = Familyable::Person.new(id: 4, parent_ids: []),
16
16
  e = Familyable::Person.new(id: 5, parent_ids: [2]),
17
17
  ],
@@ -59,7 +59,7 @@ describe Familyable::Family do
59
59
  persons: [
60
60
  a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
61
61
  b = Familyable::Person.new(id: 2, parent_ids: []),
62
- c = Familyable::Person.new(id: 3, parent_ids: [4],),
62
+ c = Familyable::Person.new(id: 3, parent_ids: [4], ),
63
63
  d = Familyable::Person.new(id: 4, parent_ids: []),
64
64
  e = Familyable::Person.new(id: 5, parent_ids: [2]),
65
65
  ],
@@ -107,7 +107,7 @@ describe Familyable::Family do
107
107
  persons: [
108
108
  a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
109
109
  b = Familyable::Person.new(id: 2, parent_ids: []),
110
- c = Familyable::Person.new(id: 3, parent_ids: [4],),
110
+ c = Familyable::Person.new(id: 3, parent_ids: [4], ),
111
111
  d = Familyable::Person.new(id: 4, parent_ids: [3]),
112
112
  e = Familyable::Person.new(id: 5, parent_ids: [2]),
113
113
  ],
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Numeric do
6
+ context :to_oct_html_table do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: '1-3 case',
11
+ from: 1,
12
+ to: 3,
13
+ expected: <<-EOS
14
+ <table>
15
+ <tr>
16
+ <th>10digit</th>
17
+ <th>8digit</th>
18
+ </tr>
19
+ <tr>
20
+ <td>1</td>
21
+ <td>1</td>
22
+ </tr>
23
+ <tr>
24
+ <td>2</td>
25
+ <td>2</td>
26
+ </tr>
27
+ <tr>
28
+ <td>3</td>
29
+ <td>3</td>
30
+ </tr>
31
+ </table>
32
+ EOS
33
+ },
34
+ {
35
+ case_no: 2,
36
+ case_title: '65535-65536 case',
37
+ from: 65_535,
38
+ to: 65_536,
39
+ expected: <<-EOS
40
+ <table>
41
+ <tr>
42
+ <th>10digit</th>
43
+ <th>8digit</th>
44
+ </tr>
45
+ <tr>
46
+ <td>65535</td>
47
+ <td>177777</td>
48
+ </tr>
49
+ <tr>
50
+ <td>65536</td>
51
+ <td>200000</td>
52
+ </tr>
53
+ </table>
54
+ EOS
55
+ },
56
+ ]
57
+
58
+ cases.each do |c|
59
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
60
+ begin
61
+ case_before c
62
+
63
+ # -- given --
64
+ # nothing
65
+
66
+ # -- when --
67
+ actual = Numeric.to_oct_html_table(c[:from], c[:to])
68
+
69
+ # -- then --
70
+ expect(actual).to eq(c[:expected])
71
+ ensure
72
+ case_after c
73
+ end
74
+ end
75
+
76
+ def case_before(c)
77
+ # implement each case before
78
+ end
79
+
80
+ def case_after(c)
81
+ # implement each case after
82
+ end
83
+ end
84
+ end
85
+ 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.98
4
+ version: 0.0.99
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-04-15 00:00:00.000000000 Z
12
+ date: 2014-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &22226724 !ruby/object:Gem::Requirement
16
+ requirement: &27100056 !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: *22226724
24
+ version_requirements: *27100056
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &22223076 !ruby/object:Gem::Requirement
27
+ requirement: &27098940 !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: *22223076
35
+ version_requirements: *27098940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &21382872 !ruby/object:Gem::Requirement
38
+ requirement: &27098280 !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: *21382872
46
+ version_requirements: *27098280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &21379212 !ruby/object:Gem::Requirement
49
+ requirement: &27096024 !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: *21379212
57
+ version_requirements: *27096024
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &25948188 !ruby/object:Gem::Requirement
60
+ requirement: &27094056 !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: *25948188
68
+ version_requirements: *27094056
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp
@@ -164,6 +164,7 @@ files:
164
164
  - lib/open_classes/numeric/to_digit_table.rb
165
165
  - lib/open_classes/numeric/to_hex_html_table.rb
166
166
  - lib/open_classes/numeric/to_hex_table.rb
167
+ - lib/open_classes/numeric/to_oct_html_table.rb
167
168
  - lib/open_classes/numeric/to_oct_table.rb
168
169
  - lib/open_classes/object.rb
169
170
  - lib/open_classes/object/any_of.rb
@@ -276,6 +277,7 @@ files:
276
277
  - spec/open_classes/numeric/to_digit_table_spec.rb
277
278
  - spec/open_classes/numeric/to_hex_html_table_spec.rb
278
279
  - spec/open_classes/numeric/to_hex_table_spec.rb
280
+ - spec/open_classes/numeric/to_oct_html_table_spec.rb
279
281
  - spec/open_classes/numeric/to_oct_table_spec.rb
280
282
  - spec/open_classes/object/any_of_spec.rb
281
283
  - spec/open_classes/object/boolean_spec.rb
@@ -409,6 +411,7 @@ test_files:
409
411
  - spec/open_classes/numeric/to_digit_table_spec.rb
410
412
  - spec/open_classes/numeric/to_hex_html_table_spec.rb
411
413
  - spec/open_classes/numeric/to_hex_table_spec.rb
414
+ - spec/open_classes/numeric/to_oct_html_table_spec.rb
412
415
  - spec/open_classes/numeric/to_oct_table_spec.rb
413
416
  - spec/open_classes/object/any_of_spec.rb
414
417
  - spec/open_classes/object/boolean_spec.rb