Class: RubyStackoverflow::Client::ResponseData
- Inherits:
-
Object
- Object
- RubyStackoverflow::Client::ResponseData
- Defined in:
- lib/ruby-stackoverflow/client/response_data.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#has_more ⇒ Object
readonly
Returns the value of attribute has_more.
Instance Method Summary collapse
- #format_data(data, klass) ⇒ Object
-
#initialize(response, klass) ⇒ ResponseData
constructor
A new instance of ResponseData.
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/ruby-stackoverflow/client/response_data.rb', line 4 def data @data end |
#error ⇒ Object (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_more ⇒ Object (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 |