Class: YARD::CodeObjects::CodeObjectList

Inherits:
Array
  • Object
show all
Defined in:
lib/yard/code_objects/base.rb

Overview

A list of code objects. This array acts like a set (no unique items) but also disallows any Proxy objects from being added.

Instance Method Summary

Methods inherited from Array

#place

Constructor Details

- (CodeObjectList) initialize(owner = Registry.root)

Creates a new object list associated with a namespace

Parameters:

  • (NamespaceObject) owner (defaults to: Registry.root) — the namespace the list should be associated with


10
11
12
# File 'lib/yard/code_objects/base.rb', line 10

def initialize(owner = Registry.root)
  @owner = owner
end

Instance Method Details

- (Object) <<



27
28
29
30
31
32
33
34
35
# File 'lib/yard/code_objects/base.rb', line 27

def push(value)
  value = Proxy.new(@owner, value) if value.is_a?(String) || value.is_a?(Symbol)
  if value.is_a?(CodeObjects::Base) || value.is_a?(Proxy)
    super(value) unless include?(value)
  else
    raise ArgumentError, "#{value.class} is not a valid CodeObject"
  end
  self
end

- (CodeObjectList) push(value) Also known as: <<

Adds a new value to the list

Parameters:

  • (Base) value — a code object to add

Returns:



18
19
20
21
22
23
24
25
26
# File 'lib/yard/code_objects/base.rb', line 18

def push(value)
  value = Proxy.new(@owner, value) if value.is_a?(String) || value.is_a?(Symbol)
  if value.is_a?(CodeObjects::Base) || value.is_a?(Proxy)
    super(value) unless include?(value)
  else
    raise ArgumentError, "#{value.class} is not a valid CodeObject"
  end
  self
end