sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 98112f87859c9c38fb01f6341b8cfc705813d8d9
parent 5728946f67fca5f5b42ea565f04572c643346272
Author: Whyme Lyu <callme5long@gmail.com>
Date:   Sun, 14 Jul 2013 19:56:49 +0800

s/methods.include?/respond_to?

Diffstat:
M bin/sup | 4 ++--
M lib/sup/buffer.rb | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -290,7 +290,7 @@ begin
       b.mode.load_in_background if new
     when :search
       completions = LabelManager.all_labels.map { |l| "label:#{LabelManager.string_for l}" }
-      completions = completions.each { |l| l.force_encoding 'UTF-8' if l.methods.include?(:encoding) }
+      completions = completions.each { |l| l.force_encoding 'UTF-8' if l.respond_to?(:encoding) }
       completions += ["from:", "to:", "after:", "before:", "date:", "limit:", "AND", "OR", "NOT"]
       query = BufferManager.ask_many_with_completions :search, "Search all messages (enter for saved searches): ", completions
       unless query.nil?
@@ -304,7 +304,7 @@ begin
       SearchResultsMode.spawn_from_query "is:unread"
     when :list_labels
       labels = LabelManager.all_labels.map { |l| LabelManager.string_for l }
-      labels = labels.each { |l| l.force_encoding 'UTF-8' if l.methods.include?(:encoding) }
+      labels = labels.each { |l| l.force_encoding 'UTF-8' if l.respond_to?(:encoding) }
 
       user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels
       unless user_label.nil?
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -450,7 +450,7 @@ EOS
 
   def ask_with_completions domain, question, completions, default=nil
     ask domain, question, default do |s|
-      s.force_encoding 'UTF-8' if s.methods.include?(:encoding)
+      s.force_encoding 'UTF-8' if s.respond_to?(:encoding)
       completions.select { |x| x =~ /^#{Regexp::escape s}/iu }.map { |x| [x, x] }
     end
   end
@@ -467,8 +467,8 @@ EOS
           raise "william screwed up completion: #{partial.inspect}"
         end
 
-      prefix.force_encoding 'UTF-8' if prefix.methods.include?(:encoding)
-      target.force_encoding 'UTF-8' if target.methods.include?(:encoding)
+      prefix.force_encoding 'UTF-8' if prefix.respond_to?(:encoding)
+      target.force_encoding 'UTF-8' if target.respond_to?(:encoding)
       completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] }
     end
   end
@@ -477,10 +477,10 @@ EOS
     ask domain, question, default do |partial|
       prefix, target = partial.split_on_commas_with_remainder
       target ||= prefix.pop || ""
-      target.force_encoding 'UTF-8' if target.methods.include?(:encoding)
+      target.force_encoding 'UTF-8' if target.respond_to?(:encoding)
 
       prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ")
-      prefix.force_encoding 'UTF-8' if prefix.methods.include?(:encoding)
+      prefix.force_encoding 'UTF-8' if prefix.respond_to?(:encoding)
 
       completions.select { |x| x =~ /^#{Regexp::escape target}/i }.sort_by { |c| [ContactManager.contact_for(c) ? 0 : 1, c] }.map { |x| [prefix + x, x] }
     end