Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move logic to private method

  • Loading branch information...
commit 6081372876aa15f5d26534db091918cca797d40b 1 parent 4d1e5c3
@chinghanho authored
Showing with 10 additions and 9 deletions.
  1. +10 −9 lib/chh_moretext.rb
View
19 lib/chh_moretext.rb
@@ -7,19 +7,20 @@ class Base
class << self
def fetch_moretext(number, limit)
number = "n=#{number}"
-
- if limit.is_a?(Range)
- limit = "limit=#{limit.min},#{limit.max}"
- elsif limit.is_a?(Integer)
- limit = "limit=#{limit}"
- else
- limit = nil
- end
-
+ limit = parse(limit)
condition = limit.nil? ? "?#{number}" : "?#{number}&#{limit}"
return JSON(open("http://more.handlino.com/sentences.json#{condition}").read)["sentences"]
end
end
+
+ private
+ def self.parse(type)
+ case type
+ when Range then "limit=#{type.min},#{type.max}"
+ when Integer then "limit=#{type}"
+ else nil
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.