Sha256: 21065bc2d0c0c17d6ea1f2ee9f1a8c2687b72c8d4f45867138af271af7eac6ed

Contents?: true

Size: 674 Bytes

Versions: 2

Compression:

Stored size: 674 Bytes

Contents

require "chh_moretext/version"
require "json"
require "open-uri"

module ChhMoretext
  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

        if limit.nil?
          condition = "?#{number}"
        else
          condition = "?#{number}&#{limit}"
        end
        return JSON(open("http://more.handlino.com/sentences.json#{condition}").read)["sentences"]
      end
    end
  end
end

require "chh_moretext/moretext"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chh_moretext-0.1.1 lib/chh_moretext.rb
chh_moretext-0.1.0 lib/chh_moretext.rb