Class: Etna::Clients::Metis::TailNode

Inherits:
Response
  • Object
show all
Defined in:
lib/etna/clients/metis/models.rb

Instance Attribute Summary

Attributes inherited from Response

#raw

Instance Method Summary collapse

Methods inherited from Response

params

Constructor Details

#initialize(tail, raw = {}) ⇒ TailNode

Returns a new instance of TailNode.



238
239
240
241
# File 'lib/etna/clients/metis/models.rb', line 238

def initialize(tail, raw = {})
  super(raw)
  @tail = tail
end

Instance Method Details

#as_fileObject



257
258
259
260
261
262
263
264
265
266
267
# File 'lib/etna/clients/metis/models.rb', line 257

def as_file
  {
    file_name: node_name,
    file_hash: file_hash,
    updated_at: updated_at,
    file_path: file_path,
    folder_id: parent_id,
    project_name: @tail.project_name,
    bucket_name: @tail.bucket_name,
  }
end

#file?Boolean

Returns:

  • (Boolean)


251
252
253
# File 'lib/etna/clients/metis/models.rb', line 251

def file?
  @raw[:type] == 'file'
end

#file_pathObject



280
281
282
# File 'lib/etna/clients/metis/models.rb', line 280

def file_path
  [ parent_path, node_name ].compact.join('/')
end

#folder?Boolean

Returns:

  • (Boolean)


247
248
249
# File 'lib/etna/clients/metis/models.rb', line 247

def folder?
  @raw[:type] == 'folder'
end

#parent?Boolean

Returns:

  • (Boolean)


243
244
245
# File 'lib/etna/clients/metis/models.rb', line 243

def parent?
  @raw[:type] == 'parent'
end

#parent_pathObject



269
270
271
272
273
274
275
276
277
278
# File 'lib/etna/clients/metis/models.rb', line 269

def parent_path
  return nil if !parent_id

  if !@tail.paths[parent_id]
    parent = @tail.parents[parent_id]
    @tail.paths[parent_id] = parent.file_path
  end

  return @tail.paths[parent_id]
end