Sha256: 915207f3ee540652b53d2d9a81415396742dee5a031392df87acbb61e34e17d3

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

require 'erb'
require 'social_url/version'
require 'social_url/message'
require 'social_url/facebook'
require 'social_url/twitter'

module SocialUrl
  include ERB::Util

  class << self
    NETWORKS = [:twitter]

    def networks
      NETWORKS
    end

    def normalize(options)
      opts = {}

      options.each do |key, value|
        next unless value

        opts[key] = normalize_string(value) if value.is_a?(String)
        opts[key] = normalize_array(value) if value.is_a?(Array)
      end

      opts
    end

    def normalize_string(string)
      ERB::Util.url_encode(string)
    end

    def normalize_array(array)
      array.collect do |value|
        ERB::Util.url_encode(value)
      end.join(',')
    end
  end

  class UnsupportedNetworkError < StandardError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
social-url-0.1.1 lib/social_url.rb