Class: UCD::Formatter::Base

Inherits:
Object
  • Object
show all
Includes:
HasAttributes
Defined in:
lib/ucd/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

Returns a new instance of Base.



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

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

Instance Attribute Details

#typeObject

Returns the value of attribute type.



35
36
37
# File 'lib/ucd/formatter/base.rb', line 35

def type
  @type
end

Class Method Details

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



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

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

.inherited(subclass) ⇒ Object



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

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

.nameObject



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

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

Instance Method Details

#format(node) ⇒ Object



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

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 Node::Document          then format_document(node)
  end
end

#format_class(node) ⇒ Object

Raises:

  • (NotImplementedError)


56
# File 'lib/ucd/formatter/base.rb', line 56

def format_class(node);              raise NotImplementedError; end

#format_class_relationship(node) ⇒ Object

Raises:

  • (NotImplementedError)


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

def format_class_relationship(node); raise NotImplementedError; end

#format_document(node) ⇒ Object

Raises:

  • (NotImplementedError)


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

def format_document(node);           raise NotImplementedError; end

#format_field(node) ⇒ Object

Raises:

  • (NotImplementedError)


52
# File 'lib/ucd/formatter/base.rb', line 52

def format_field(node);              raise NotImplementedError; end

#format_method(node) ⇒ Object

Raises:

  • (NotImplementedError)


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

def format_method(node);             raise NotImplementedError; end

#format_relationship(node) ⇒ Object

Raises:

  • (NotImplementedError)


54
# File 'lib/ucd/formatter/base.rb', line 54

def format_relationship(node);       raise NotImplementedError; end

#nameObject



31
32
33
# File 'lib/ucd/formatter/base.rb', line 31

def name
  self.class.name
end