tbpgr_utils 0.0.116 → 0.0.117
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +51 -0
- data/README.md +13 -1
- data/Rakefile +8 -8
- data/lib/attributes_initializable.rb +3 -3
- data/lib/eval_helper/attr_init_class_code.rb +1 -1
- data/lib/eval_helper/times_code.rb +2 -2
- data/lib/markdown/heading.rb +32 -32
- data/lib/open_classes/array/kernel_send.rb +15 -0
- data/lib/open_classes/array/to_table.rb +1 -1
- data/lib/open_classes/array.rb +1 -0
- data/lib/open_classes/kernel/aa_ancestors.rb +16 -16
- data/lib/open_classes/kernel/p_evals.rb +42 -42
- data/lib/open_classes/string/heading_helper.rb +1 -1
- data/lib/open_classes/string/stripe.rb +1 -1
- data/lib/open_classes/string/to_hatena_heading.rb +35 -35
- data/lib/open_classes/string/to_markdown_heading.rb +37 -37
- data/lib/open_classes/string/to_space2_heading.rb +35 -35
- data/lib/open_classes/string/to_space4_heading.rb +35 -35
- data/lib/open_classes/string/to_tab_heading.rb +35 -35
- data/lib/simple_tournament.rb +57 -57
- data/lib/tbpgr_utils/version.rb +1 -1
- data/rubocop-todo.yml +33 -33
- data/spec/markdown/heading_spec.rb +4 -4
- data/spec/markdown/ol_spec.rb +1 -1
- data/spec/markdown/ul_spec.rb +1 -1
- data/spec/open_classes/array/kernel_send_spec.rb +43 -0
- data/spec/open_classes/array/together_at_spec.rb +61 -61
- data/spec/open_classes/array/together_clear_spec.rb +51 -51
- data/spec/open_classes/array/together_concat_spec.rb +53 -53
- data/spec/open_classes/array/together_delete_at_spec.rb +78 -78
- data/spec/open_classes/array/together_delete_if_spec.rb +61 -61
- data/spec/open_classes/array/together_delete_spec.rb +80 -80
- data/spec/open_classes/array/together_fill_spec.rb +79 -79
- data/spec/open_classes/array/together_map_spec.rb +171 -171
- data/spec/open_classes/array/together_spec.rb +51 -51
- data/spec/open_classes/array/together_with_index_spec.rb +51 -51
- data/spec/open_classes/object/any_of_spec.rb +72 -72
- data/spec/set_variables_code_spec.rb +2 -1
- data/tbpgr_utils.gemspec +27 -27
- metadata +41 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 813189dd7e2699c513dae05b50d5f841d6e4a7b1
|
4
|
+
data.tar.gz: 6be348d263542c013e45cc81e80475397b386f4b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e1479071b4c5feec294716ce25aad060e9f7f8559398234a2af3b1bc913a09355f3df92bcf170654859f4556bbf7e8047f93933f7c636a0d9d3b0d1b6f08c4b5
|
7
|
+
data.tar.gz: bf240a5a702bb16b636815c8aae1adb783193a16550cebbe3b764aa1fc4ea4b309bdf7a591888b3b6eeee1f853ee93e6ac9166154627d35f9fc989bd8da5931f
|
data/.rubocop.yml
CHANGED
@@ -4,3 +4,54 @@ LineLength:
|
|
4
4
|
Enabled: false
|
5
5
|
Semicolon:
|
6
6
|
Enabled: false
|
7
|
+
|
8
|
+
AccessModifierIndentation:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
AsciiComments:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Documentation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
EmptyLineBetweenDefs:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
EmptyLines:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
EmptyLinesAroundAccessModifier:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Encoding:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Eval:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Lambda:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
MethodLength:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
NestedTernaryOperator:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
ParenthesesAroundCondition:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
RaiseArgs:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
ShadowingOuterLocalVariable:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
UselessAssignment:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
WordArray:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
OpMethod:
|
57
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -24,7 +24,8 @@ Or install it yourself as:
|
|
24
24
|
### List
|
25
25
|
| class/module/method | mean |
|
26
26
|
|:----------- |:------------ |
|
27
|
-
|[TbpgrUtils Array#>>](#array)
|
27
|
+
|[TbpgrUtils Array#>>](#array) |alias of map(&:method_symbol) |
|
28
|
+
|[TbpgrUtils Array#kernel_send](#arraykernel_send) |alias of map {|v|send :some_kernel_method, v} |
|
28
29
|
|[TbpgrUtils Array#to_table](#arrayto_table) |Array(Array, Array...) to table format. |
|
29
30
|
|[TbpgrUtils Array#to_html_table](#arrayto_html_table) |Array(Array, Array...) to html table format. |
|
30
31
|
|[TbpgrUtils Array#together](#arraytogether) |loop all arrays by block |
|
@@ -167,6 +168,16 @@ require 'tbpgr_utils'
|
|
167
168
|
|
168
169
|
[back to list](#list)
|
169
170
|
|
171
|
+
### Array#kernel_send
|
172
|
+
~~~ruby
|
173
|
+
require 'tbpgr_utils'
|
174
|
+
[*1..3].kernel_send:Rational # => [(1/1), (2/1), (3/1)]
|
175
|
+
[*1..3].kernel_send:print # => 123
|
176
|
+
[*65..68].kernel_send :putc # => ABCD
|
177
|
+
~~~
|
178
|
+
|
179
|
+
[back to list](#list)
|
180
|
+
|
170
181
|
### Array#to_table
|
171
182
|
~~~ruby
|
172
183
|
require 'tbpgr_utils'
|
@@ -3524,6 +3535,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
3524
3535
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
3525
3536
|
|
3526
3537
|
## History
|
3538
|
+
* version 0.0.117 : add Array#kernel_send
|
3527
3539
|
* version 0.0.116 : add Array#>>
|
3528
3540
|
* version 0.0.115 : add MarkdownString#codes
|
3529
3541
|
* version 0.0.114 : add MarkdownString#code
|
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require 'rspec/core'
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
task :
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
8
|
-
end
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
task default: [:spec]
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
8
|
+
end
|
@@ -47,16 +47,16 @@ module AttributesInitializable
|
|
47
47
|
def generate_attr(symbols, type)
|
48
48
|
results = symbols.reduce([]) do |results, sym|
|
49
49
|
fail TypeError, "invalid type #{sym.class}. you have to use Symbol" unless sym.class == Symbol
|
50
|
-
results << ":#{sym
|
50
|
+
results << ":#{sym}"
|
51
51
|
end
|
52
|
-
class_eval "attr_#{type
|
52
|
+
class_eval "attr_#{type} #{results.join(',')}"
|
53
53
|
end
|
54
54
|
|
55
55
|
def generate_initializer(symbols)
|
56
56
|
instance_eval do
|
57
57
|
define_method :initialize do |values = nil, &block|
|
58
58
|
return block.call self if block
|
59
|
-
symbols.each { |symbol|instance_variable_set("@#{symbol
|
59
|
+
symbols.each { |symbol|instance_variable_set("@#{symbol}", values[symbol]) }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -49,10 +49,10 @@ module EvalHelper
|
|
49
49
|
# end
|
50
50
|
#
|
51
51
|
def times_code(number, proc)
|
52
|
-
return "#{number
|
52
|
+
return "#{number}.times { |i| #{proc} }" if proc.count('\n') == 0
|
53
53
|
indented = proc.split('\n').reduce([]) { |ret, v|ret << " #{v}" ; ret }.join("\n")
|
54
54
|
<<-EOS
|
55
|
-
#{number
|
55
|
+
#{number}.times do |i|
|
56
56
|
#{indented}
|
57
57
|
end
|
58
58
|
EOS
|
data/lib/markdown/heading.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class MarkdownString
|
4
|
-
class << self
|
5
|
-
# Return markdown heading level1-6 from text
|
6
|
-
#
|
7
|
-
# === Example
|
8
|
-
#
|
9
|
-
# MarkdownString.heading1("title") # => "# title"
|
10
|
-
# MarkdownString.heading2("title") # => "## title"
|
11
|
-
# MarkdownString.heading3("title") # => "### title"
|
12
|
-
# MarkdownString.heading4("title") # => "#### title"
|
13
|
-
# MarkdownString.heading5("title") # => "##### title"
|
14
|
-
# MarkdownString.heading6("title") # => "###### title"
|
15
|
-
# MarkdownString.heading1("") # => "# "
|
16
|
-
# MarkdownString.heading1(nil) # => "# "
|
17
|
-
# MarkdownString.heading1(12345) # => "# 12345"
|
18
|
-
#
|
19
|
-
[*1..6].each do |i|
|
20
|
-
define_method "heading#{i
|
21
|
-
heading(text, i)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class MarkdownString
|
4
|
+
class << self
|
5
|
+
# Return markdown heading level1-6 from text
|
6
|
+
#
|
7
|
+
# === Example
|
8
|
+
#
|
9
|
+
# MarkdownString.heading1("title") # => "# title"
|
10
|
+
# MarkdownString.heading2("title") # => "## title"
|
11
|
+
# MarkdownString.heading3("title") # => "### title"
|
12
|
+
# MarkdownString.heading4("title") # => "#### title"
|
13
|
+
# MarkdownString.heading5("title") # => "##### title"
|
14
|
+
# MarkdownString.heading6("title") # => "###### title"
|
15
|
+
# MarkdownString.heading1("") # => "# "
|
16
|
+
# MarkdownString.heading1(nil) # => "# "
|
17
|
+
# MarkdownString.heading1(12345) # => "# 12345"
|
18
|
+
#
|
19
|
+
[*1..6].each do |i|
|
20
|
+
define_method "heading#{i}".to_sym do |text|
|
21
|
+
heading(text, i)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def self.heading(text, level)
|
28
|
+
return '#' * level + ' ' if text.nil?
|
29
|
+
return '#' * level + ' ' if text.respond_to?(:empty) && text.empty?
|
30
|
+
'#' * level + " #{text}"
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Array
|
4
|
+
class Array
|
5
|
+
# alias of map {|v|send :some_kernel_method, v}
|
6
|
+
#
|
7
|
+
# === Example
|
8
|
+
#
|
9
|
+
# [*1..3].kernel_send:Rational # => [(1/1), (2/1), (3/1)]
|
10
|
+
#
|
11
|
+
def kernel_send(method_name)
|
12
|
+
return self unless [Symbol, String].include? method_name.class
|
13
|
+
map { |v|send method_name.to_sym, v }
|
14
|
+
end
|
15
|
+
end
|
@@ -16,7 +16,7 @@ class Array
|
|
16
16
|
def to_table(position = :right)
|
17
17
|
ret = reduce([]) do |rets, lines|
|
18
18
|
ret = lines.reduce([]) { |ret, column|ret << column; ret }
|
19
|
-
rets << "|#{ret.join(
|
19
|
+
rets << "|#{ret.join('|')}|"
|
20
20
|
end.join("\n") + "\n"
|
21
21
|
ret.justify_table(position)
|
22
22
|
end
|
data/lib/open_classes/array.rb
CHANGED
@@ -47,24 +47,24 @@ module Kernel
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def max_size_class
|
51
|
+
ancestors.max_by { |v|v.to_s.size }
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
def centered_ancestors(max)
|
55
|
+
ancestors.reverse.map { |v|v.to_s.center max }
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def surrounded_ancestors(ca)
|
59
|
+
ca.reduce([]) { |ret, k|ret << k.surround }
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
def connected_box_ancestors(ba, max)
|
63
|
+
ba.join(ancestors_connector(max))
|
64
|
+
end
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def ancestors_connector(max)
|
67
|
+
connector = '|'.rjust((max + 2) / 2)
|
68
|
+
"\n#{connector}\n"
|
69
|
+
end
|
70
70
|
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Kernel
|
4
|
-
module Kernel
|
5
|
-
# Print code + eval result
|
6
|
-
#
|
7
|
-
# print_eval 8/4, binding # => 8/4 # => 2
|
8
|
-
# message = 'msg';print_eval "hoge-#{message}", binding # => "hoge-#{message}" # => "hoge-msg"
|
9
|
-
def print_eval(code, binding)
|
10
|
-
print exec_eval code, binding
|
11
|
-
end
|
12
|
-
|
13
|
-
# Puts code + eval result
|
14
|
-
#
|
15
|
-
# puts_eval 8/4, binding # => 8/4 # => 2\n
|
16
|
-
# message = 'msg';puts_eval "hoge-#{message}", binding # => "hoge-#{message}" # => "hoge-msg"\n
|
17
|
-
def puts_eval(code, binding)
|
18
|
-
puts exec_eval code, binding
|
19
|
-
end
|
20
|
-
|
21
|
-
# Puts each-line-code + eval result
|
22
|
-
#
|
23
|
-
# code
|
24
|
-
# message = 'msg'
|
25
|
-
# puts_eval binding, <<-EOS
|
26
|
-
# "hoge-#{message}1"
|
27
|
-
# "hoge-#{message}2"
|
28
|
-
# EOS
|
29
|
-
#
|
30
|
-
# result
|
31
|
-
# "hoge-#{message}1" # => "hoge-msg1"\n
|
32
|
-
# "hoge-#{message}2" # => "hoge-msg2"\n
|
33
|
-
def bulk_puts_eval(binding, codes)
|
34
|
-
codes.each_line { |code|puts_eval(code.chop, binding) }
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Kernel
|
4
|
+
module Kernel
|
5
|
+
# Print code + eval result
|
6
|
+
#
|
7
|
+
# print_eval 8/4, binding # => 8/4 # => 2
|
8
|
+
# message = 'msg';print_eval "hoge-#{message}", binding # => "hoge-#{message}" # => "hoge-msg"
|
9
|
+
def print_eval(code, binding)
|
10
|
+
print exec_eval code, binding
|
11
|
+
end
|
12
|
+
|
13
|
+
# Puts code + eval result
|
14
|
+
#
|
15
|
+
# puts_eval 8/4, binding # => 8/4 # => 2\n
|
16
|
+
# message = 'msg';puts_eval "hoge-#{message}", binding # => "hoge-#{message}" # => "hoge-msg"\n
|
17
|
+
def puts_eval(code, binding)
|
18
|
+
puts exec_eval code, binding
|
19
|
+
end
|
20
|
+
|
21
|
+
# Puts each-line-code + eval result
|
22
|
+
#
|
23
|
+
# code
|
24
|
+
# message = 'msg'
|
25
|
+
# puts_eval binding, <<-EOS
|
26
|
+
# "hoge-#{message}1"
|
27
|
+
# "hoge-#{message}2"
|
28
|
+
# EOS
|
29
|
+
#
|
30
|
+
# result
|
31
|
+
# "hoge-#{message}1" # => "hoge-msg1"\n
|
32
|
+
# "hoge-#{message}2" # => "hoge-msg2"\n
|
33
|
+
def bulk_puts_eval(binding, codes)
|
34
|
+
codes.each_line { |code|puts_eval(code.chop, binding) }
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def exec_eval(code, binding)
|
39
|
+
ret = eval code, binding
|
40
|
+
"#{code} # => #{ret.inspect}"
|
41
|
+
end
|
42
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'active_support/core_ext/object/inclusion'
|
3
|
-
require 'open_classes/string/heading_helper'
|
4
|
-
|
5
|
-
class String
|
6
|
-
include HeadingHelper
|
7
|
-
# Hatena
|
8
|
-
HATENA = '*'
|
9
|
-
|
10
|
-
# create heading string with Emmet-like syntax.
|
11
|
-
#
|
12
|
-
# ==== Examples
|
13
|
-
#
|
14
|
-
# > case
|
15
|
-
#
|
16
|
-
# 'hoge>hige'.to_hatena_heading # => '*hoge\n**hige'
|
17
|
-
#
|
18
|
-
# + case
|
19
|
-
#
|
20
|
-
# 'hoge+hige'.to_hatena_heading # => '*hoge\n*hige'
|
21
|
-
#
|
22
|
-
# ^ case
|
23
|
-
#
|
24
|
-
# 'hoge>hige^hege'.to_hatena_heading # => '*hoge\n**hige\n*hege'
|
25
|
-
#
|
26
|
-
def to_hatena_heading
|
27
|
-
heading = to_heading
|
28
|
-
to_hatena heading
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'active_support/core_ext/object/inclusion'
|
3
|
+
require 'open_classes/string/heading_helper'
|
4
|
+
|
5
|
+
class String
|
6
|
+
include HeadingHelper
|
7
|
+
# Hatena
|
8
|
+
HATENA = '*'
|
9
|
+
|
10
|
+
# create heading string with Emmet-like syntax.
|
11
|
+
#
|
12
|
+
# ==== Examples
|
13
|
+
#
|
14
|
+
# > case
|
15
|
+
#
|
16
|
+
# 'hoge>hige'.to_hatena_heading # => '*hoge\n**hige'
|
17
|
+
#
|
18
|
+
# + case
|
19
|
+
#
|
20
|
+
# 'hoge+hige'.to_hatena_heading # => '*hoge\n*hige'
|
21
|
+
#
|
22
|
+
# ^ case
|
23
|
+
#
|
24
|
+
# 'hoge>hige^hege'.to_hatena_heading # => '*hoge\n**hige\n*hege'
|
25
|
+
#
|
26
|
+
def to_hatena_heading
|
27
|
+
heading = to_heading
|
28
|
+
to_hatena heading
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def to_hatena(heading)
|
33
|
+
to_head(heading, HATENA, start_level: 1)
|
34
|
+
end
|
35
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'active_support/core_ext/object/inclusion'
|
3
|
-
require 'open_classes/string/heading_helper'
|
4
|
-
|
5
|
-
class String
|
6
|
-
include HeadingHelper
|
7
|
-
# Markdown
|
8
|
-
MARKDOWN = '#'
|
9
|
-
# Separator
|
10
|
-
SEPARATOR = ' '
|
11
|
-
|
12
|
-
# create heading string with Emmet-like syntax.
|
13
|
-
#
|
14
|
-
# ==== Examples
|
15
|
-
#
|
16
|
-
# > case
|
17
|
-
#
|
18
|
-
# 'hoge>hige'.to_markdown_heading # => '# hoge\n## hige'
|
19
|
-
#
|
20
|
-
# + case
|
21
|
-
#
|
22
|
-
# 'hoge+hige'.to_markdown_heading # => '# hoge\n# hige'
|
23
|
-
#
|
24
|
-
# ^ case
|
25
|
-
#
|
26
|
-
# 'hoge>hige^hege'.to_markdown_heading # => '# hoge\n## hige\n# hege'
|
27
|
-
#
|
28
|
-
def to_markdown_heading
|
29
|
-
heading = to_heading
|
30
|
-
to_markdown heading
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'active_support/core_ext/object/inclusion'
|
3
|
+
require 'open_classes/string/heading_helper'
|
4
|
+
|
5
|
+
class String
|
6
|
+
include HeadingHelper
|
7
|
+
# Markdown
|
8
|
+
MARKDOWN = '#'
|
9
|
+
# Separator
|
10
|
+
SEPARATOR = ' '
|
11
|
+
|
12
|
+
# create heading string with Emmet-like syntax.
|
13
|
+
#
|
14
|
+
# ==== Examples
|
15
|
+
#
|
16
|
+
# > case
|
17
|
+
#
|
18
|
+
# 'hoge>hige'.to_markdown_heading # => '# hoge\n## hige'
|
19
|
+
#
|
20
|
+
# + case
|
21
|
+
#
|
22
|
+
# 'hoge+hige'.to_markdown_heading # => '# hoge\n# hige'
|
23
|
+
#
|
24
|
+
# ^ case
|
25
|
+
#
|
26
|
+
# 'hoge>hige^hege'.to_markdown_heading # => '# hoge\n## hige\n# hege'
|
27
|
+
#
|
28
|
+
def to_markdown_heading
|
29
|
+
heading = to_heading
|
30
|
+
to_markdown heading
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def to_markdown(heading)
|
35
|
+
to_head(heading, MARKDOWN, separator: SEPARATOR, start_level: 1)
|
36
|
+
end
|
37
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'active_support/core_ext/object/inclusion'
|
3
|
-
require 'open_classes/string/heading_helper'
|
4
|
-
|
5
|
-
class String
|
6
|
-
include HeadingHelper
|
7
|
-
# Space2
|
8
|
-
SPACE2 = ' '
|
9
|
-
|
10
|
-
# create heading string with Emmet-like syntax.
|
11
|
-
#
|
12
|
-
# ==== Examples
|
13
|
-
#
|
14
|
-
# > case
|
15
|
-
#
|
16
|
-
# 'hoge>hige'.to_space2_heading # => 'hoge\n hige'
|
17
|
-
#
|
18
|
-
# + case
|
19
|
-
#
|
20
|
-
# 'hoge+hige'.to_space2_heading # => 'hoge\nhige'
|
21
|
-
#
|
22
|
-
# ^ case
|
23
|
-
#
|
24
|
-
# 'hoge>hige^hege'.to_space2_heading # => 'hoge\n hige\nhege'
|
25
|
-
#
|
26
|
-
def to_space2_heading
|
27
|
-
heading = to_heading
|
28
|
-
to_space2 heading
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'active_support/core_ext/object/inclusion'
|
3
|
+
require 'open_classes/string/heading_helper'
|
4
|
+
|
5
|
+
class String
|
6
|
+
include HeadingHelper
|
7
|
+
# Space2
|
8
|
+
SPACE2 = ' '
|
9
|
+
|
10
|
+
# create heading string with Emmet-like syntax.
|
11
|
+
#
|
12
|
+
# ==== Examples
|
13
|
+
#
|
14
|
+
# > case
|
15
|
+
#
|
16
|
+
# 'hoge>hige'.to_space2_heading # => 'hoge\n hige'
|
17
|
+
#
|
18
|
+
# + case
|
19
|
+
#
|
20
|
+
# 'hoge+hige'.to_space2_heading # => 'hoge\nhige'
|
21
|
+
#
|
22
|
+
# ^ case
|
23
|
+
#
|
24
|
+
# 'hoge>hige^hege'.to_space2_heading # => 'hoge\n hige\nhege'
|
25
|
+
#
|
26
|
+
def to_space2_heading
|
27
|
+
heading = to_heading
|
28
|
+
to_space2 heading
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def to_space2(heading)
|
33
|
+
to_head(heading, SPACE2)
|
34
|
+
end
|
35
|
+
end
|