Class: RubyLokaliseApi::Collections::V1::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, RubyLokaliseApi::Concerns::AttrsLoadable, Utils::Attributes
Includes:
Enumerable, Utils::Keys
Defined in:
lib/ruby_lokalise_api/collections/v1/base.rb

Overview

Base collection. Collection is an array of resources. The actual resources can be found by calling the .collection method

Direct Known Subclasses

AuditLogs

Constant Summary collapse

ATTRS_FILENAME =
'collection_attributes.yml'

Constants included from Utils::Attributes

Utils::Attributes::UNIFIED_RESOURCES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RubyLokaliseApi::Concerns::AttrsLoadable

extended, inherited

Methods included from Utils::Keys

#collection_key_for, #data_key_for

Constructor Details

#initialize(response) ⇒ Base

Returns a new instance of Base.



23
24
25
26
27
28
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 23

def initialize(response)
  @self_endpoint = response.endpoint

  populate_common_attrs_from response
  produce_collection_from response
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



21
22
23
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 21

def collection
  @collection
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



21
22
23
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 21

def has_more
  @has_more
end

#next_cursorObject (readonly)

Returns the value of attribute next_cursor.



21
22
23
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 21

def next_cursor
  @next_cursor
end

Instance Method Details

#load_next_cursorObject

Tries to fetch the next cursor for paginated collection Returns a new collection or nil if the next cursor is not available



32
33
34
35
36
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 32

def load_next_cursor
  return nil unless next_cursor?

  fetch_cursor(next_cursor)
end

#next_cursor?Boolean

Checks whether the next cursor is available

Returns:

  • (Boolean)


40
41
42
# File 'lib/ruby_lokalise_api/collections/v1/base.rb', line 40

def next_cursor?
  !next_cursor.nil? && next_cursor != ''
end