Sha256: ccc39e9f8096f1e4397fb3e3ff6977ebdda6e7b5c3d1770e02c6fd66bbfe68a5

Contents?: true

Size: 716 Bytes

Versions: 74

Compression:

Stored size: 716 Bytes

Contents

/**
* Here is an example solution for the Bob exercise
*/
component {
		
	function response( heyBob ) {
		heyBob = heyBob
			.trim()
			.reReplaceNoCase( '[^a-z?]', '' );
		
		if( !heyBob.len() ) {
			return 'Fine. Be that way!';
		}
		
		if( isScreaming( heyBob ) && isQuestion( heyBob ) ) {
			return 'Calm down, I know what I''m doing!';
		}
		
		if( isScreaming( heyBob ) ) {
			return 'Whoa, chill out!';
		}
		
		if( isQuestion( heyBob ) ) {
			return 'Sure.';
		}
		
		return 'Whatever.';
		
	}
	
	private function isScreaming( heyBob ) {
		return heyBob.reFindNoCase( '[a-z]' ) && compare( heyBob, heyBob.uCase() ) == 0;
	}
	
	private function isQuestion( heyBob ) {
		return heyBob.right( 1 ) == '?';
	}
	
}

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.179 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.178 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.177 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.176 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.175 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.174 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.173 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.172 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.171 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.170 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.169 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.167 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.166 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.165 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.164 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.163 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.162 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.161 tracks/cfml/exercises/bob/Solution.cfc
trackler-2.2.1.160 tracks/cfml/exercises/bob/Solution.cfc