Sha256: 9af0d266394623c86857af392dfec0e92d37b0b441804233fc50034404e4bbd4

Contents?: true

Size: 760 Bytes

Versions: 5

Compression:

Stored size: 760 Bytes

Contents

module StackExchange
  module StackOverflow
    class Badge < Base

      extend Forwardable

      def_delegators :@struct, :badge_id, :rank, :name, :description,
                               :award_count, :tag_based, :badges_recipients_url

      class << self 

        def all(options = {})
          method = select_method(options)
          request(method, nil, options)
        end

        def select_method(options)
          tag_based = options[:tag_based] || options['tag_based']
          tag_based ? '/badges/tags' : '/badges'
        end

        def parse(response)
          parse_with_class(response, 'badges', Badge)
          OpenStruct.new response
        end
      end

      def id
        @struct.badge_id
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pilha-0.2.1 lib/pilha/stack_overflow/badge.rb
pilha-0.2.0 lib/pilha/stack_overflow/badge.rb
pilha-0.1.9 lib/pilha/stack_overflow/badge.rb
pilha-0.1.8 lib/pilha/stack_overflow/badge.rb
pilha-0.1.7 lib/pilha/stack_overflow/badge.rb