Class: CDP::Timeline::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cdp/timeline/response.rb

Defined Under Namespace

Classes: Paging

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success: true, items: [], paging: nil, error: nil) ⇒ Response

Returns a new instance of Response.

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
# File 'lib/cdp/timeline/response.rb', line 19

def initialize(success: true, items: [], paging: nil, error: nil)
  raise ArgumentError, "Invalid paging object." if paging && !paging.is_a?(Paging)

  @success = success
  @items = items
  @paging = paging || Paging.new
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



17
18
19
# File 'lib/cdp/timeline/response.rb', line 17

def error
  @error
end

#itemsObject (readonly)

Returns the value of attribute items.



17
18
19
# File 'lib/cdp/timeline/response.rb', line 17

def items
  @items
end

#pagingObject (readonly)

Returns the value of attribute paging.



17
18
19
# File 'lib/cdp/timeline/response.rb', line 17

def paging
  @paging
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/cdp/timeline/response.rb', line 32

def error?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/cdp/timeline/response.rb', line 28

def success?
  !!@success
end