Class: SequenceDiagram::Participant

Inherits:
Object
  • Object
show all
Defined in:
lib/yard-sd/sequence_diagram/participant.rb

Constant Summary collapse

@@uid =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, aliasing, distance = nil, thread = false) ⇒ Participant

Returns a new instance of Participant


9
10
11
12
13
14
15
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 9

def initialize(name, aliasing, distance = nil, thread = false)
  @name = name
  @aliasing = aliasing
  @distance = distance
  @thread   = thread
  @uid = @@uid += 1
end

Instance Attribute Details

#aliasingObject (readonly)

Returns the value of attribute aliasing


8
9
10
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 8

def aliasing
  @aliasing
end

#distanceObject (readonly)

Returns the value of attribute distance


6
7
8
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 6

def distance
  @distance
end

#nameObject (readonly)

Returns the value of attribute name


5
6
7
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 5

def name
  @name
end

#uidObject (readonly)

Returns the value of attribute uid


7
8
9
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 7

def uid
  @uid
end

Instance Method Details

#==(other) ⇒ Object


26
27
28
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 26

def ==(other)
  @uid == other.uid
end

#to_sObject


17
18
19
20
21
22
23
24
# File 'lib/yard-sd/sequence_diagram/participant.rb', line 17

def to_s
  cmd = @thread ? "newthread" : "newinst"
  if @distance.nil?
    "\\#{cmd}{#@uid}{#{SequenceDiagram.latex_escape(@name)}}"
  else
    "\\#{cmd}[#@distance]{#@uid}{#{SequenceDiagram.latex_escape(@name)}}"
  end
end