rot13 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rot13.rb +4 -3
  2. metadata +1 -1
@@ -6,11 +6,12 @@ class Rot13
6
6
 
7
7
  def self.rotate(s,deg=13)
8
8
 
9
- a = ((65..90).to_a + (97..122).to_a).map.with_index{|x,i| [x.chr,i] }
9
+ a = ('a'..'z').map.with_index{|x,i| [x.chr,i] }
10
10
 
11
11
  r = s.split(//).map do |x|
12
- item = a.assoc(x)
13
- item ? a.rotate(deg)[item.last].first : x
12
+ item = a.assoc(x.downcase)
13
+ c = item ? a.rotate(deg)[item.last].first : x
14
+ x == x.downcase ? c : c.upcase
14
15
  end
15
16
 
16
17
  r.join
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rot13
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson