Sha256: 5f28ca47d8484763f365a1350bb8001deddd560a0aef317a5d4c722606b171e2

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

module StackExchange
  module StackOverflow
    class Comment 
      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 = {})
          options.merge! :id => id
          response = client.request('/comments/:id/', options)

          comment = Comment.new(response['comments'].first)
          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

2 entries across 2 versions & 1 rubygems

Version Path
pilha-0.1.3 lib/pilha/stack_overflow/comment.rb
pilha-0.1.2 lib/pilha/stack_overflow/comment.rb