Class: Hiptest::Nodes::Folder

Inherits:
Node
  • Object
show all
Defined in:
lib/hiptest-publisher/nodes.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #parent

Instance Method Summary collapse

Methods inherited from Node

#==, #each_direct_children, #each_sub_nodes, #flat_string, #kind, #pretty_print_instance_variables, #project, #render

Constructor Details

#initialize(uid, parent_uid, name, description, tags = [], order_in_parent = 0, body = []) ⇒ Folder

Returns a new instance of Folder.



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/hiptest-publisher/nodes.rb', line 481

def initialize(uid, parent_uid, name, description, tags = [], order_in_parent = 0, body = [])
  super()
  @uid = uid
  @parent_uid = parent_uid
  @order_in_parent = order_in_parent

  @children = {
    name: name,
    description: description,
    subfolders: [],
    scenarios: [],
    tags: tags,
    body: body
  }
end

Instance Attribute Details

#order_in_parentObject (readonly)

Returns the value of attribute order_in_parent.



479
480
481
# File 'lib/hiptest-publisher/nodes.rb', line 479

def order_in_parent
  @order_in_parent
end

#parent_uidObject (readonly)

Returns the value of attribute parent_uid.



479
480
481
# File 'lib/hiptest-publisher/nodes.rb', line 479

def parent_uid
  @parent_uid
end

#uidObject (readonly)

Returns the value of attribute uid.



479
480
481
# File 'lib/hiptest-publisher/nodes.rb', line 479

def uid
  @uid
end

Instance Method Details

#ancestorsObject



505
506
507
508
509
510
511
512
513
514
515
# File 'lib/hiptest-publisher/nodes.rb', line 505

def ancestors
  ancestors = []

  current_ancestor = folder
  until current_ancestor.nil?
    ancestors << current_ancestor
    current_ancestor = current_ancestor.folder
  end

  ancestors
end

#folderObject



501
502
503
# File 'lib/hiptest-publisher/nodes.rb', line 501

def folder
  root? ? nil : parent
end

#root?Boolean

Returns:

  • (Boolean)


497
498
499
# File 'lib/hiptest-publisher/nodes.rb', line 497

def root?
  parent_uid == nil
end