module Tinify

Constants

VERSION

Attributes

app_identifier[R]
compression_count[RW]
key[R]
proxy[R]

Public Class Methods

app_identifier=(app_identifier) click to toggle source
# File lib/tinify.rb, line 23
def app_identifier=(app_identifier)
  @app_identifier = app_identifier
  @client = nil
end
client() click to toggle source
# File lib/tinify.rb, line 56
def client
  raise AccountError.new("Provide an API key with Tinify.key = ...") unless key
  return @client if @client
  @@mutex.synchronize do
    @client ||= Client.new(key, app_identifier, proxy).freeze
  end
end
from_buffer(string) click to toggle source
# File lib/tinify.rb, line 37
def from_buffer(string)
  Source.from_buffer(string)
end
from_file(path) click to toggle source
# File lib/tinify.rb, line 33
def from_file(path)
  Source.from_file(path)
end
from_url(string) click to toggle source
# File lib/tinify.rb, line 41
def from_url(string)
  Source.from_url(string)
end
key=(key) click to toggle source
# File lib/tinify.rb, line 18
def key=(key)
  @key = key
  @client = nil
end
proxy=(proxy) click to toggle source
# File lib/tinify.rb, line 28
def proxy=(proxy)
  @proxy = proxy
  @client = nil
end
validate!() click to toggle source
# File lib/tinify.rb, line 45
def validate!
  client.request(:post, "/shrink")
rescue AccountError => err
  return true if err.status == 429
  raise err
rescue ClientError
  true
end