Sha256: 762d93ed3c9d0dc9326f9d987a9bd86e4700cbb8aa735fa95fea369e1e1da73c

Contents?: true

Size: 779 Bytes

Versions: 11

Compression:

Stored size: 779 Bytes

Contents

module Tumblr
  module Helper

    private

    def blog_path(blog_name, ext)
      "v2/blog/#{full_blog_name(blog_name)}/#{ext}"
    end

    def full_blog_name(blog_name)
      blog_name.include?('.') ? blog_name : "#{blog_name}.tumblr.com"
    end

    def validate_options(valid_opts, opts)
      bad_opts = opts.select { |val| !valid_opts.include?(val) }
      if bad_opts.any?
        raise ArgumentError.new "Invalid options (#{bad_opts.keys.join(', ')}) passed, only #{valid_opts} allowed."
      end
    end

    def validate_no_collision(options, attributes)
      count = attributes.count { |attr| options.has_key?(attr) }
      if count > 1
        raise ArgumentError.new "Can only use one of: #{attributes.join(', ')} (Found #{count})"
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
doomy_client-0.8.5 lib/tumblr/helpers.rb
tumblr_client-0.8.5 lib/tumblr/helpers.rb
tumblr_client-0.8.4 lib/tumblr/helpers.rb
tumblr_client-0.8.3 lib/tumblr/helpers.rb
tumblr_client-0.8.2 lib/tumblr/helpers.rb
tumblr_client-0.8.1 lib/tumblr/helpers.rb
tumblr_client-0.7.5 lib/tumblr/helpers.rb
tumblr_client-0.7.4 lib/tumblr/helpers.rb
tumblr_client-0.7.3 lib/tumblr/helpers.rb
tumblr_client-0.7.2 lib/tumblr/helpers.rb
tumblr_client-0.7.1 lib/tumblr/helpers.rb