File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ require 'minitest/autorun'
2+ require_relative 'acronym'
3+
4+ class AcronymTest < Minitest ::Test
5+ def test_png
6+ assert_equal 'PNG' , Acronym . abbreviate ( 'Portable Network Graphics' )
7+ end
8+
9+ def test_ruby_on_rails
10+ skip
11+ assert_equal 'ROR' , Acronym . abbreviate ( 'Ruby on Rails' )
12+ end
13+
14+ def test_html
15+ skip
16+ assert_equal 'HTML' , Acronym . abbreviate ( 'HyperText Markup Language' )
17+ end
18+
19+ def test_fifo
20+ skip
21+ assert_equal 'FIFO' , Acronym . abbreviate ( 'First In, First Out' )
22+ end
23+
24+ def test_php
25+ skip
26+ assert_equal 'PHP' , Acronym . abbreviate ( 'PHP: Hypertext Preprocessor' )
27+ end
28+
29+ def test_cmos
30+ skip
31+ assert_equal 'CMOS' , Acronym . abbreviate ( 'Complementary metal-oxide semiconductor' )
32+ end
33+ end
Original file line number Diff line number Diff line change 1+ class Acronym
2+ def self . abbreviate ( phrase )
3+ [ ] . tap do |letters |
4+ each_word ( phrase ) do |word |
5+ letters << word [ 0 ] . upcase
6+ end
7+ end . join
8+ end
9+
10+ def self . each_word ( phrase )
11+ phrase . scan ( /[A-Z]+[a-z]*|[a-z]+/ ) do |word |
12+ yield word
13+ end
14+ end
15+ end
Original file line number Diff line number Diff line change 88 " gigasecond" ,
99 " rna-transcription" ,
1010 " raindrops" ,
11+ " acronym" ,
1112 " difference-of-squares" ,
1213 " roman-numerals" ,
1314 " robot-name" ,
You can’t perform that action at this time.
0 commit comments