Sha256: 6c1fe8421b8aa33fb3f4849df3d833e23e7b18a693fce2e75e4c16bcdfee475e
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
# coding: utf-8 # Singleton class for cure echo class CureEchoManager module EchoMode TRANSFORM = 1 ATTACK = 2 end def initialize @in = $stdin @out = $stdout @err = $stderr @cure_name = 'echo' @message_mode = EchoMode::TRANSFORM end def source_output(source = $stdout) @out = source end def source_input(source = $stdin) @in = source end def source_err(source = $stderr) @err = source end def precure(cure_name = false) @cure_name = cure_name || 'echo' end def msg_transform(flag = true) @message_mode = EchoMode::TRANSFORM if flag end def msg_attack(flag = false) @message_mode = EchoMode::ATTACK if flag end def nosleep(flag = true) Rubicure::Girl.sleep_sec = 1 Rubicure::Girl.sleep_sec = 0 if flag end def print_results return 1 unless existing_precure? if @message_mode == EchoMode::TRANSFORM Cure.send(@cure_name.to_sym).transform! elsif @message_mode == EchoMode::ATTACK Cure.send(@cure_name.to_sym).transform! Cure.send(@cure_name.to_sym).attack! end 0 end private def existing_precure? found_precure = Rubicure::Girl.config.find do |k, _v| k == @cure_name.to_sym end if found_precure true else @err.puts "No such precure #{@cure_name}" false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cureutils-0.2.0 | lib/cureutils/cure_echo_manager.rb |
cureutils-0.1.5 | lib/cureutils/cure_echo_manager.rb |