module PIM::XML::Parameters

Constants

CHUNK_SIZE
PARAMETERS

Public Instance Methods

get_chunk_range() click to toggle source
# File xml/helpers.rb, line 54
def get_chunk_range
  chunk_nr = get_chunk_nr || 0
  chunk_size = get_chunk_size || CHUNK_SIZE
  chunk_offset = get_chunk_offset || 0
  chunk_start = (chunk_nr * chunk_size) + chunk_offset
  chunk_end = (chunk_nr + 1) * chunk_size - 1
  (chunk_start..chunk_end)
end
is_in_chunk_range?(current_item: nil, current_chunk: nil) click to toggle source

Checks if either the ‘current_item’ or ‘current_chunk’ is in the transformer’s ‘range’. To be in the “range”, the transformer must have had a ‘chunk_nr’ set. Thus, this method can also be used to check if a transformer should only “count” the items, because then ‘chunk_nr’ is nil!

Note: ‘current_item’ and ‘current_chunk’ begin counting at 0!

# File xml/helpers.rb, line 39
def is_in_chunk_range? current_item: nil, current_chunk: nil

  # Ensure a 'chunk_nr' was specified to the transform call!
  return false if get_chunk_nr.nil?

  # If 'current_chunk' specified, only check that
  return true if !current_chunk.nil? and get_chunk_nr == current_chunk

  # Check if 'item_number' is in the expected range
  return true if !current_item.nil? and get_chunk_range.include?(current_item)

  return false

end