class Common

Class includes common methos which are refered from multiple commands.

Public Class Methods

cure_list(sym) click to toggle source
# 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) click to toggle source
# 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) click to toggle source

Convert string to precure regular expression

# 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