Sha256: 194f5f568352989a2c378567e8cd39635c0443b0f92c088f7dbbdafbf2bc8a89

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module StackExchange
  module StackOverflow
    class Comment < Base
      extend Forwardable

      def_delegators :@struct, :comment_id, :creation_date, :owner, :post_id,
                     :post_type, :score, :body

      class << self 
        attr_reader :client

        def find_by_id(id, options = {})
          request('/comments/:id/', id, options)
        end

        def find_by_question_id(id, options = {})
          request('/questions/:id/comments', id, options)
        end

        def find_by_user_id(id, options = {})
          request('/users/:id/comments', id, options)
        end

        private
          def parse(response)
            response['comments'].each do |comment|
              parse_with_class(comment, 'owner', User)
            end
            parse_with_class(response, 'comments', Comment)
            OpenStruct.new response
          end
      end

      def initialize(hash)
        @struct = OpenStruct.new hash
      end

      def id
        @struct.comment_id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pilha-0.1.5 lib/pilha/stack_overflow/comment.rb