Class: RubyStackoverflow::Client::ResponseData

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-stackoverflow/client/response_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, klass) ⇒ ResponseData

Returns a new instance of ResponseData.



6
7
8
9
10
11
12
13
# File 'lib/ruby-stackoverflow/client/response_data.rb', line 6

def initialize(response, klass)
  if response[:items].nil?
    @error = StackoverflowError.new(response)
  else
    @data = format_data(response[:items], klass)
    @has_more = response[:has_more]
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/ruby-stackoverflow/client/response_data.rb', line 4

def data
  @data
end

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/ruby-stackoverflow/client/response_data.rb', line 4

def error
  @error
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



4
5
6
# File 'lib/ruby-stackoverflow/client/response_data.rb', line 4

def has_more
  @has_more
end

Instance Method Details

#format_data(data, klass) ⇒ Object



15
16
17
# File 'lib/ruby-stackoverflow/client/response_data.rb', line 15

def format_data(data, klass)
  eval(klass.capitalize).parse_data(data)
end