Class: Gitlab::Ci::Tags::TagList

Inherits:
Array
  • Object
show all
Defined in:
lib/gitlab/ci/tags/tag_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TagList

Returns a new instance of TagList.



9
10
11
12
# File 'lib/gitlab/ci/tags/tag_list.rb', line 9

def initialize(*args)
  @parser = Parser
  add(*args)
end

Instance Attribute Details

#ownerObject

Returns the value of attribute owner.



7
8
9
# File 'lib/gitlab/ci/tags/tag_list.rb', line 7

def owner
  @owner
end

#parserObject

Returns the value of attribute parser.



7
8
9
# File 'lib/gitlab/ci/tags/tag_list.rb', line 7

def parser
  @parser
end

Instance Method Details

#+(other) ⇒ Object



25
26
27
# File 'lib/gitlab/ci/tags/tag_list.rb', line 25

def +(other)
  TagList.new.add(self).add(other)
end

#<<(obj) ⇒ Object



21
22
23
# File 'lib/gitlab/ci/tags/tag_list.rb', line 21

def <<(obj)
  add(obj)
end

#add(*names) ⇒ Object



14
15
16
17
18
19
# File 'lib/gitlab/ci/tags/tag_list.rb', line 14

def add(*names)
  extract_and_apply_options!(names)
  concat(names)
  clean!
  self
end

#concat(other_tag_list) ⇒ Object



29
30
31
32
# File 'lib/gitlab/ci/tags/tag_list.rb', line 29

def concat(other_tag_list)
  super(other_tag_list).clean!
  self
end

#remove(*names) ⇒ Object



34
35
36
37
38
# File 'lib/gitlab/ci/tags/tag_list.rb', line 34

def remove(*names)
  extract_and_apply_options!(names)
  delete_if { |name| names.include?(name) }
  self
end

#to_sObject



40
41
42
43
44
45
46
47
# File 'lib/gitlab/ci/tags/tag_list.rb', line 40

def to_s
  tags = frozen? ? dup : self
  tags.clean!

  tags.map do |name|
    name.index(',') ? "\"#{name}\"" : name
  end.join(', ')
end