Class: Archimate::Svg::Entity::ServiceEntity

Inherits:
RoundedRectEntity show all
Defined in:
lib/archimate/svg/entity/service_entity.rb

Instance Attribute Summary

Attributes inherited from BaseEntity

#background_class, #badge, #badge_bounds, #bounds_offset, #child, #entity, #text_bounds

Instance Method Summary collapse

Methods inherited from BaseEntity

#entity_badge, #entity_label, #group_attrs, #optional_link, #shape_style, #text_lines, #text_style, #to_svg

Constructor Details

#initialize(child, bounds_offset) ⇒ ServiceEntity

Returns a new instance of ServiceEntity.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/archimate/svg/entity/service_entity.rb', line 7

def initialize(child, bounds_offset)
  super
  bounds = child.bounds
  @badge = "#archimate-service-badge"
  @text_bounds = DataModel::Bounds.new(
    x: bounds.left + 7,
    y: bounds.top + 5,
    width: bounds.width - 14,
    height: bounds.height - 10
  )
end

Instance Method Details

#entity_shape(xml, bounds) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/archimate/svg/entity/service_entity.rb', line 19

def entity_shape(xml, bounds)
  case child.child_type
  when "1"
    service_path(xml, bounds)
    @badge = nil
  else
    super
  end
end

#service_path(xml, bounds) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/archimate/svg/entity/service_entity.rb', line 29

def service_path(xml, bounds)
  xml.rect(
    x: bounds.left,
    y: bounds.top,
    width: bounds.width,
    height: bounds.height,
    rx: bounds.height / 2.0,
    ry: bounds.height / 2.0,
    class: background_class,
    style: shape_style
  )
end