Skip to content

Commit

Permalink
Use casecmp instead of downcase ==
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 19, 2016
1 parent d6023b8 commit a649ba5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/t/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def does_contain(user_list, user = nil)
desc 'does_follow USER [USER]', 'Find out whether one user follows another.'
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
def does_follow(user1, user2 = nil)
abort 'No, you are not following yourself.' if user2.nil? && user1 == @rcfile.active_profile[0].downcase
abort 'No, you are not following yourself.' if user2.nil? && @rcfile.active_profile[0].casecmp(user1).zero?
abort "No, @#{user1} is not following themself." if user1 == user2
require 't/core_ext/string'
thread1 = if options['id']
Expand Down
2 changes: 1 addition & 1 deletion lib/t/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def mute(user, *users)
def account(account, key = nil)
if key && @rcfile.profiles[account].keys.length == 1
continue = ask 'There is only one API key associated with this account, removing it will disable all functionality, are you sure you want to delete it? [y/N]'
return if continue.downcase != 'y'
return unless continue.casecmp('y').zero?
elsif key
return @rcfile.delete_key(account, key)
else
Expand Down
4 changes: 2 additions & 2 deletions lib/t/rcfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def find(username)
end

def find_case_insensitive_match(username)
profiles.keys.detect { |u| username.downcase == u.downcase }
profiles.keys.detect { |u| username.casecmp(u).zero? }
end

def find_case_insensitive_possibilities(username)
profiles.keys.select { |u| username.downcase == u.downcase[0, username.length] }
profiles.keys.select { |u| username.casecmp(u[0, username.length]).zero? }
end

def []=(username, profile)
Expand Down

0 comments on commit a649ba5

Please sign in to comment.