Class: Common
- Inherits:
-
Object
- Object
- Common
- Defined in:
- lib/cureutils/common.rb
Overview
Class includes common methos which are refered from multiple commands.
Class Method Summary collapse
- .cure_list(sym) ⇒ Object
- .cure_table(to_sym, from_sym) ⇒ Object
-
.pregex2regex(regex, br_flg = false) ⇒ Object
Convert string to precure regular expression.
Class Method Details
.cure_list(sym) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cureutils/common.rb', line 21 def cure_list(sym) list = Precure.all_girls.map(&sym) list << Cure.echo[sym] # Regulate cure princes human name list.map do |str| str.gsub!(/\(.+?\)/, '') str end list end |
.cure_table(to_sym, from_sym) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/cureutils/common.rb', line 32 def cure_table(to_sym, from_sym) to_arr = cure_list(to_sym) from_arr = cure_list(from_sym) hash = Hash[[to_arr, from_arr].transpose] hash end |
.pregex2regex(regex, br_flg = false) ⇒ Object
Convert string to precure regular expression
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cureutils/common.rb', line 9 def pregex2regex(regex, br_flg = false) this_regex = regex.dup br_ex = br_flg ? '' : '?:' %w(girl_name human_name precure_name cast_name color).each do |attr| expression = '\[:' + attr + ':\]' precures_ex = cure_list(attr.to_sym).join('|') replaced = "(#{br_ex}#{precures_ex})" this_regex.gsub!(/#{expression}/, replaced) end this_regex end |