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