Sha256: f4c6c62a0f96a6fa847a40463ab72fe6d3ea05defdba059b5542e23fbf2b66d6
Contents?: true
Size: 1002 Bytes
Versions: 3
Compression:
Stored size: 1002 Bytes
Contents
# coding: utf-8 # # Class includes common methos which are refered from multiple commands. # class Common class << self # Convert string to precure regular expression 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 def cure_list(sym) list = Precure.all_stars.map(&sym) list << Cure.echo[sym] # Regulate cure princes human name list.map do |str| str.gsub!(/\(.+?\)/, '') str end list end 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cureutils-0.2.1 | lib/cureutils/common.rb |
cureutils-0.2.0 | lib/cureutils/common.rb |
cureutils-0.1.5 | lib/cureutils/common.rb |