Class: Lutaml::Uml::Formatter::Base

Inherits:
Object
  • Object
show all
Includes:
HasAttributes
Defined in:
lib/lutaml/uml/formatter/base.rb

Direct Known Subclasses

Graphviz

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasAttributes

#update_attributes

Constructor Details

#initialize(attributes = {}) ⇒ Base

rubocop:disable Rails/ActiveRecordAliases



27
28
29
# File 'lib/lutaml/uml/formatter/base.rb', line 27

def initialize(attributes = {})
  update_attributes(attributes)
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



36
37
38
# File 'lib/lutaml/uml/formatter/base.rb', line 36

def type
  @type
end

Class Method Details

.format(node, attributes = {}) ⇒ Object



15
16
17
# File 'lib/lutaml/uml/formatter/base.rb', line 15

def format(node, attributes = {})
  new(attributes).format(node)
end

.inherited(subclass) ⇒ Object



11
12
13
# File 'lib/lutaml/uml/formatter/base.rb', line 11

def inherited(subclass)
  Formatter.all << subclass
end

.nameObject



19
20
21
# File 'lib/lutaml/uml/formatter/base.rb', line 19

def name
  to_s.split("::").last.downcase.to_sym
end

Instance Method Details

#format(node) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/lutaml/uml/formatter/base.rb', line 42

def format(node)
  case node
  when Node::Field  then format_field(node)
  when Node::Method then format_method(node)
  when Node::Relationship then format_relationship(node)
  when Node::ClassRelationship then format_class_relationship(node)
  when Node::ClassNode then format_class(node)
  when Lutaml::Uml::Document then format_document(node)
  end
end

#format_class(_node) ⇒ Object

Raises:

  • (NotImplementedError)


61
# File 'lib/lutaml/uml/formatter/base.rb', line 61

def format_class(_node);              raise NotImplementedError; end

#format_class_relationship(_node) ⇒ Object

Raises:

  • (NotImplementedError)


59
# File 'lib/lutaml/uml/formatter/base.rb', line 59

def format_class_relationship(_node); raise NotImplementedError; end

#format_document(_node) ⇒ Object

Raises:

  • (NotImplementedError)


63
# File 'lib/lutaml/uml/formatter/base.rb', line 63

def format_document(_node);           raise NotImplementedError; end

#format_field(_node) ⇒ Object

Raises:

  • (NotImplementedError)


53
# File 'lib/lutaml/uml/formatter/base.rb', line 53

def format_field(_node);              raise NotImplementedError; end

#format_method(_node) ⇒ Object

Raises:

  • (NotImplementedError)


55
# File 'lib/lutaml/uml/formatter/base.rb', line 55

def format_method(_node);             raise NotImplementedError; end

#format_relationship(_node) ⇒ Object

Raises:

  • (NotImplementedError)


57
# File 'lib/lutaml/uml/formatter/base.rb', line 57

def format_relationship(_node);       raise NotImplementedError; end

#nameObject

rubocop:enable Rails/ActiveRecordAliases



32
33
34
# File 'lib/lutaml/uml/formatter/base.rb', line 32

def name
  self.class.name
end