Class: YUML::Class
- Inherits:
-
Object
- Object
- YUML::Class
- Defined in:
- lib/yuml/class.rb
Overview
Represents a yUML Class
Instance Attribute Summary collapse
Instance Method Summary collapse
- #associated_with(dest, options = {}) ⇒ Object
- #attach_note(content, options = {}) ⇒ Object
- #has_a(dest, options = {}) ⇒ Object
-
#initialize ⇒ Class
constructor
A new instance of Class.
- #is_a(dest, options = {}) ⇒ Object
- #methods(*args) ⇒ Object
- #relationships ⇒ Object
- #to_s ⇒ Object
- #variables(*args) ⇒ Object
Constructor Details
#initialize ⇒ Class
Returns a new instance of Class.
6 7 8 9 10 |
# File 'lib/yuml/class.rb', line 6 def initialize @methods = [] @variables = [] @relationships = [] end |
Instance Attribute Details
#name(name = nil) ⇒ Object
12 13 14 15 |
# File 'lib/yuml/class.rb', line 12 def name(name = nil) @name = name if name @name end |
Instance Method Details
#associated_with(dest, options = {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/yuml/class.rb', line 41 def associated_with(dest, = {}) [:type] = :directed_assoication unless i( association directed_assoication two_way_association dependency ).include?([:type]) relationship = YUML::Relationship.send([:type], [:cardinality]) @relationships << "[#{name}]#{relationship}[#{dest.name}]" end |
#attach_note(content, options = {}) ⇒ Object
49 50 51 |
# File 'lib/yuml/class.rb', line 49 def attach_note(content, = {}) @relationships << "[#{name}]-#{YUML::Note.create(content, options)}" end |
#has_a(dest, options = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/yuml/class.rb', line 29 def has_a(dest, = {}) [:type] = :aggregation unless i(composition aggregation).include?([:type]) relationship = YUML::Relationship.send([:type], [:cardinality]) @relationships << "[#{name}]#{relationship}[#{dest.name}]" end |
#is_a(dest, options = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/yuml/class.rb', line 35 def is_a(dest, = {}) [:type] = :inheritance unless i(inheritance interface).include?([:type]) relationship = YUML::Relationship.send([:type]) @relationships << "[#{dest.name}]#{relationship}[#{name}]" end |
#methods(*args) ⇒ Object
23 24 25 26 27 |
# File 'lib/yuml/class.rb', line 23 def methods(*args) args.flatten! return attributes(@methods) if args.empty? @methods << normalize(args) end |
#relationships ⇒ Object
57 58 59 |
# File 'lib/yuml/class.rb', line 57 def relationships "#{@relationships.join(',')}" unless @relationships.empty? end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/yuml/class.rb', line 53 def to_s "[#{name}#{variables}#{methods}]" end |
#variables(*args) ⇒ Object
17 18 19 20 21 |
# File 'lib/yuml/class.rb', line 17 def variables(*args) args.flatten! return attributes(@variables) if args.empty? @variables << normalize(args) end |