Class: OntologyUnited::DSL::PseudoSet

Inherits:
Array
  • Object
show all
Defined in:
lib/ontology-united/dsl/pseudo_set.rb

Instance Method Summary collapse

Instance Method Details

#+(arr) ⇒ Object



31
32
33
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 31

def +(arr)
  concat(arr)
end

#<<(obj) ⇒ Object



21
22
23
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 21

def <<(obj)
  push(obj)
end

#add_or_fetch(obj) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 8

def add_or_fetch(obj)
  if include?(obj)
    at(index(obj))
  else
    array_push(obj)
    obj
  end
end

#array_concatObject



6
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 6

alias_method :array_concat, :concat

#array_pushObject



5
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 5

alias_method :array_push, :push

#concat(arr) ⇒ Object



25
26
27
28
29
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 25

def concat(arr)
  array = dup
  arr.each { |el| array.push(el) }
  array
end

#push(obj) ⇒ Object



17
18
19
# File 'lib/ontology-united/dsl/pseudo_set.rb', line 17

def push(obj)
  include?(obj) ? self : array_push(obj)
end