Class: UCD::Formatter::Base
- Inherits:
-
Object
- Object
- UCD::Formatter::Base
- Includes:
- HasAttributes
- Defined in:
- lib/ucd/formatter/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #format(node) ⇒ Object
- #format_class(node) ⇒ Object
- #format_class_relationship(node) ⇒ Object
- #format_document(node) ⇒ Object
- #format_field(node) ⇒ Object
- #format_method(node) ⇒ Object
- #format_relationship(node) ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
Methods included from HasAttributes
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
#type ⇒ Object
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 |
.name ⇒ Object
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
56 |
# File 'lib/ucd/formatter/base.rb', line 56 def format_class(node); raise NotImplementedError; end |
#format_class_relationship(node) ⇒ Object
55 |
# File 'lib/ucd/formatter/base.rb', line 55 def format_class_relationship(node); raise NotImplementedError; end |
#format_document(node) ⇒ Object
57 |
# File 'lib/ucd/formatter/base.rb', line 57 def format_document(node); raise NotImplementedError; end |
#format_field(node) ⇒ Object
52 |
# File 'lib/ucd/formatter/base.rb', line 52 def format_field(node); raise NotImplementedError; end |
#format_method(node) ⇒ Object
53 |
# File 'lib/ucd/formatter/base.rb', line 53 def format_method(node); raise NotImplementedError; end |
#format_relationship(node) ⇒ Object
54 |
# File 'lib/ucd/formatter/base.rb', line 54 def format_relationship(node); raise NotImplementedError; end |
#name ⇒ Object
31 32 33 |
# File 'lib/ucd/formatter/base.rb', line 31 def name self.class.name end |