Sha256: 5a37fd7a93ef69338f7f733734e1f46be4c7572655c47d7cfeebabd74b35fd90

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

require "SHOUTCLOUD/VERSION"
require "json"
require "httparty"

module SHOUTCLOUD
  class WHOOPS < StandardError; end

  def self.UPCASE(input)
    response = HTTParty.post 'http://API.SHOUTCLOUD.IO/V1/SHOUT',
                             body: JSON.generate({ "input" => input }),
                             headers: { "Content-Type" => "application/json" }
    response_hash = JSON.parse(response.body)

    raise WHOOPS if response.code != 200

    response_hash["OUTPUT"]
  end
end

class String
  @@STACK_COUNTER = 0

  alias :UPCASE :upcase
  def upcase
    @@STACK_COUNTER += 1
    ret = if @@STACK_COUNTER == 1
      SHOUTCLOUD.UPCASE(self)
    else
      self.UPCASE
    end
    @@STACK_COUNTER -= 1
    ret
  end

  def upcase!
    self.replace(SHOUTCLOUD.UPCASE(self))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
SHOUTCLOUD-3.0.0 lib/SHOUTCLOUD.rb
SHOUTCLOUD-2.0.0 lib/SHOUTCLOUD.rb