lib/rubicure/girl.rb in rubicure-0.1.0 vs lib/rubicure/girl.rb in rubicure-0.1.1

- old
+ new

@@ -2,27 +2,29 @@ # Precure girl (ex. Cure Peace, Cure Rosetta, Cure Honey) # # this is record of "config/girls.yml" class Girl attr_reader :human_name, :precure_name, :transform_message, :extra_names, - :current_state, :state_names, :created_date, :attack_messages + :current_state, :state_names, :created_date, :attack_messages, + :transform_calls @@cache = {} @@config = nil @@sleep_sec = 1 def initialize(human_name: nil, precure_name: nil, transform_message: nil, extra_names: [], - created_date: nil, attack_messages: []) + created_date: nil, attack_messages: [], transform_calls: []) @human_name = human_name @precure_name = precure_name @transform_message = transform_message @extra_names = extra_names || [] @created_date = created_date @current_state = 0 @state_names = [@human_name, @precure_name] @state_names += @extra_names unless @extra_names.empty? @attack_messages = [""] + attack_messages + @transform_calls = transform_calls end def ==(other) other.is_a?(self.class) && self.human_name == other.human_name end @@ -118,8 +120,18 @@ message.each_line do |line| sleep(@@sleep_sec) if index > 0 puts line index += 1 end + end + + def method_missing(method_name, *args) + shortened_name = method_name.to_s. + sub(%r/\Aprecure_|_precure\z/, ""). + sub(%r/!\z/, "") + + return transform!(*args) if @transform_calls.include?(shortened_name) + + super end end end