Class: Group

Inherits:
GraphicObject show all
Includes:
CoreBase
Defined in:
app/models/group.rb

Overview

Attributes:

Instance Method Summary (collapse)

Methods inherited from GraphicObject

#get_all_descendants, #get_display_attributes_svg, #get_display_attributes_xml

Instance Method Details

- (Object) to_legacy_json(options = {})



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/group.rb', line 35

def to_legacy_json(options = {})
  gos = get_all_descendants
  json = "{\"type\":\"#{type}\", \"id\":#{id}, \"order\":#{order.nil? ? :null : order}, \"parent_id\":#{parent_id.nil? ? :null : parent_id}, \"group_label_id\":#{graphic_group_label.id.nil? ? :null : graphic_group_label.id}, \"group_label\":#{graphic_group_label.name.nil? ? :null : "\""+graphic_group_label.name+"\""}, \"sub_image_id\":#{sub_image.nil? ? :null : sub_image.id}, "
  unless gos == nil
    count = 0
    json << "\"graphic_objects\":["
    gos.each do |go|
      json << ', ' if count > 0
      json << go.to_json(options)
      count += 1
    end
    json << "]"
  end
  json << "}"
end

- (Object) to_legacy_xml(options = {})



23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/group.rb', line 23

def to_legacy_xml(options = {})
  gos = get_all_descendants
  xml = "<#{type} id='#{id}' order='#{order}' parent_id='#{parent_id}' group_label_id='#{graphic_group_label.id}' group_label='#{graphic_group_label.name}' sub_image_id='#{sub_image.nil? ? nil : sub_image.id}' "
  xml << get_display_attributes_xml + ">"
  unless gos == nil
    gos.each {|go|
      xml << "\t" << go.to_legacy_xml(options)
    }
  end
  xml << "</#{type}>"
end

- (Object) to_svg



11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/group.rb', line 11

def to_svg
  gos = get_all_descendants
  svg = "<g id=\"#{id}\" order=\"#{order}\" parent_id=\"#{parent_id}\" graphic_group_label_id=\"#{graphic_group_label.id}\" graphic_group_label=\"#{graphic_group_label.name}\" sub_image_id=\"#{sub_image.nil? ? nil : sub_image.id}\""
  svg << get_display_attributes_svg + ">"
  unless gos == nil
    gos.each {|go|
      svg << go.to_svg
    }
  end
  svg << "</g>"
end