Class: DeepL::Resources::TranslationMemorySegments
- Defined in:
- lib/deepl/resources/translation_memory_segments.rb
Overview
One page of the segments of a translation memory. Pagination is cursor-based: pass
next_page_cursor as the page_cursor option of the next request until it is nil.
Instance Attribute Summary collapse
-
#next_page_cursor ⇒ Object
readonly
Returns the value of attribute next_page_cursor.
-
#segment_count ⇒ Object
readonly
Returns the value of attribute segment_count.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(segments_response, *args) ⇒ TranslationMemorySegments
constructor
A new instance of TranslationMemorySegments.
-
#next_page? ⇒ true
Checks whether another page of segments can be requested.
- #to_s ⇒ Object
Constructor Details
#initialize(segments_response, *args) ⇒ TranslationMemorySegments
Returns a new instance of TranslationMemorySegments.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/deepl/resources/translation_memory_segments.rb', line 53 def initialize(segments_response, *args) super(*args) @segments = (segments_response['segments'] || []).map do |segment| TranslationMemorySegment.new(segment) end # Note that this is the number of segments stored in the translation memory, it is not # reduced by a text filter. @segment_count = segments_response['segment_count'] || 0 @next_page_cursor = segments_response['next_page_cursor'] end |
Instance Attribute Details
#next_page_cursor ⇒ Object (readonly)
Returns the value of attribute next_page_cursor.
51 52 53 |
# File 'lib/deepl/resources/translation_memory_segments.rb', line 51 def next_page_cursor @next_page_cursor end |
#segment_count ⇒ Object (readonly)
Returns the value of attribute segment_count.
51 52 53 |
# File 'lib/deepl/resources/translation_memory_segments.rb', line 51 def segment_count @segment_count end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
51 52 53 |
# File 'lib/deepl/resources/translation_memory_segments.rb', line 51 def segments @segments end |
Instance Method Details
#next_page? ⇒ true
Checks whether another page of segments can be requested.
69 70 71 |
# File 'lib/deepl/resources/translation_memory_segments.rb', line 69 def next_page? !next_page_cursor.nil? end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/deepl/resources/translation_memory_segments.rb', line 73 def to_s "#{segments.size} of #{segment_count} segment(s)" end |