tbpgr_utils 0.0.97 → 0.0.98

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -102,6 +102,7 @@ Or install it yourself as:
102
102
  |[TbpgrUtils Numeric to_binary_table](#numeric-to_binary_table) |binary table |
103
103
  |[TbpgrUtils Numeric to_digit_html_table](#numeric-to_digit_html_table) |digit html table |
104
104
  |[TbpgrUtils Numeric to_digit_table](#numeric-to_digit_table) |digit table |
105
+ |[TbpgrUtils Numeric to_hex_html_table](#numeric-to_hex_html_table) |hex html table |
105
106
  |[TbpgrUtils Numeric to_hex_table](#numeric-to_hex_table) |hex table |
106
107
  |[TbpgrUtils Numeric to_oct_table](#numeric-to_oct_table) |oct table |
107
108
  |[TbpgrUtils Object#any_of?](#objectany_of) |if self match any one of items, return true |
@@ -2477,6 +2478,33 @@ result
2477
2478
 
2478
2479
  [back to list](#list)
2479
2480
 
2481
+ ### Numeric to_hex_html_table
2482
+ 65535 to 65536 case
2483
+ ~~~ruby
2484
+ require 'tbpgr_utils'
2485
+ Numeric.to_hex_html_table(65535, 65536)
2486
+ ~~~
2487
+
2488
+ result
2489
+ ~~~
2490
+ <table>
2491
+ <tr>
2492
+ <th>10digit</th>
2493
+ <th>16digit</th>
2494
+ </tr>
2495
+ <tr>
2496
+ <td>65535</td>
2497
+ <td>0000ffff</td>
2498
+ </tr>
2499
+ <tr>
2500
+ <td>65536</td>
2501
+ <td>00010000</td>
2502
+ </tr>
2503
+ </table>
2504
+ ~~~
2505
+
2506
+ [back to list](#list)
2507
+
2480
2508
  ### Numeric to_hex_table
2481
2509
  65535 to 65536 case
2482
2510
  ~~~ruby
@@ -3168,6 +3196,8 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3168
3196
  https://github.com/tbpgr/tbpgr_utils_snippets
3169
3197
 
3170
3198
  ## History
3199
+ * version 0.0.98 : add Numeric.to_hex_html_table
3200
+ * version 0.0.97 : add Numeric.to_digit_html_table
3171
3201
  * version 0.0.96 : add Numeric.to_binary_html_table
3172
3202
  * version 0.0.95 : add Hash#html_table
3173
3203
  * version 0.0.94 : add String#unescape_quote
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ # Numeric
4
+ class Numeric
5
+ # return is hex table
6
+ #
7
+ # ==== Examples
8
+ #
9
+ # 65535 to 65536 case
10
+ #
11
+ # Numeric.to_hex_html_table(65535, 65536)
12
+ #
13
+ # result
14
+ #
15
+ # <table>
16
+ # <tr>
17
+ # <th>10digit</th>
18
+ # <th>16digit</th>
19
+ # </tr>
20
+ # <tr>
21
+ # <td>65535</td>
22
+ # <td>0000ffff</td>
23
+ # </tr>
24
+ # <tr>
25
+ # <td>65536</td>
26
+ # <td>00010000</td>
27
+ # </tr>
28
+ # </table>
29
+ #
30
+ def self.to_hex_html_table(from = 1, to = 10)
31
+ ret = []
32
+ size = to.to_s(16).size - 1
33
+ pad = (size / 4 + 1) * 4
34
+ ret << "<table>\n <tr>\n <th>10digit</th>\n <th>16digit</th>\n </tr>"
35
+ (from..to).each { |i|ret << " <tr>\n <td>#{i}</td>\n <td>#{i.to_s(16).rjust(pad, '0')}</td>\n </tr>" }
36
+ ret.join("\n") + "\n</table>\n"
37
+ end
38
+ end
@@ -6,5 +6,6 @@ require 'open_classes/numeric/to_binary_table'
6
6
  require 'open_classes/numeric/to_binary_html_table'
7
7
  require 'open_classes/numeric/to_digit_html_table'
8
8
  require 'open_classes/numeric/to_digit_table'
9
+ require 'open_classes/numeric/to_hex_html_table'
9
10
  require 'open_classes/numeric/to_hex_table'
10
11
  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.97'
5
+ VERSION = '0.0.98'
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_hex_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>16digit</th>
18
+ </tr>
19
+ <tr>
20
+ <td>1</td>
21
+ <td>0001</td>
22
+ </tr>
23
+ <tr>
24
+ <td>2</td>
25
+ <td>0002</td>
26
+ </tr>
27
+ <tr>
28
+ <td>3</td>
29
+ <td>0003</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>16digit</th>
44
+ </tr>
45
+ <tr>
46
+ <td>65535</td>
47
+ <td>0000ffff</td>
48
+ </tr>
49
+ <tr>
50
+ <td>65536</td>
51
+ <td>00010000</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_hex_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.97
4
+ version: 0.0.98
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-14 00:00:00.000000000 Z
12
+ date: 2014-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &2698332 !ruby/object:Gem::Requirement
16
+ requirement: &22226724 !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: *2698332
24
+ version_requirements: *22226724
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &3202644 !ruby/object:Gem::Requirement
27
+ requirement: &22223076 !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: *3202644
35
+ version_requirements: *22223076
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &3217116 !ruby/object:Gem::Requirement
38
+ requirement: &21382872 !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: *3217116
46
+ version_requirements: *21382872
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &3225036 !ruby/object:Gem::Requirement
49
+ requirement: &21379212 !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: *3225036
57
+ version_requirements: *21379212
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &3222804 !ruby/object:Gem::Requirement
60
+ requirement: &25948188 !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: *3222804
68
+ version_requirements: *25948188
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp
@@ -162,6 +162,7 @@ files:
162
162
  - lib/open_classes/numeric/to_binary_table.rb
163
163
  - lib/open_classes/numeric/to_digit_html_table.rb
164
164
  - lib/open_classes/numeric/to_digit_table.rb
165
+ - lib/open_classes/numeric/to_hex_html_table.rb
165
166
  - lib/open_classes/numeric/to_hex_table.rb
166
167
  - lib/open_classes/numeric/to_oct_table.rb
167
168
  - lib/open_classes/object.rb
@@ -273,6 +274,7 @@ files:
273
274
  - spec/open_classes/numeric/to_binary_table_spec.rb
274
275
  - spec/open_classes/numeric/to_digit_html_table_spec.rb
275
276
  - spec/open_classes/numeric/to_digit_table_spec.rb
277
+ - spec/open_classes/numeric/to_hex_html_table_spec.rb
276
278
  - spec/open_classes/numeric/to_hex_table_spec.rb
277
279
  - spec/open_classes/numeric/to_oct_table_spec.rb
278
280
  - spec/open_classes/object/any_of_spec.rb
@@ -405,6 +407,7 @@ test_files:
405
407
  - spec/open_classes/numeric/to_binary_table_spec.rb
406
408
  - spec/open_classes/numeric/to_digit_html_table_spec.rb
407
409
  - spec/open_classes/numeric/to_digit_table_spec.rb
410
+ - spec/open_classes/numeric/to_hex_html_table_spec.rb
408
411
  - spec/open_classes/numeric/to_hex_table_spec.rb
409
412
  - spec/open_classes/numeric/to_oct_table_spec.rb
410
413
  - spec/open_classes/object/any_of_spec.rb