Class: Shomen::Model::Method
- Inherits:
-
Abstract
- Object
- AbstractPrime
- Abstract
- Shomen::Model::Method
- Defined in:
- lib/shomen/model/method.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alias_for ⇒ Object
Aliases.
-
#aliases ⇒ Object
Aliases.
-
#comment ⇒ Object
Comment accompanying method definition.
-
#declarations ⇒ Object
Delarations is a list of keywords that designates characteristics about a method.
-
#dynamic ⇒ Object
Method generated dynamically?.
-
#file ⇒ Object
Filename.
-
#format ⇒ Object
Format of comment (rdoc, markdown or plain).
-
#interfaces ⇒ Object
Breakdown of interfaces signature, arguments, parameters, block argument an return values.
-
#language ⇒ Object
Source code language.
-
#line ⇒ Object
Line number.
-
#name ⇒ Object
Method’s name.
-
#namespace ⇒ Object
(also: #parent)
Method’s namespace.
-
#raises ⇒ Object
List of possible raised errors.
-
#returns ⇒ Object
List of possible returns types.
-
#singleton ⇒ Object
Singleton method ‘true` or `false/nil`.
-
#source ⇒ Object
Source code.
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ Method
constructor
A new instance of Method.
- #to_h ⇒ Object
Methods inherited from Abstract
Methods inherited from AbstractPrime
#[], #[]=, attr_accessor, type
Constructor Details
#initialize(settings = {}) ⇒ Method
Returns a new instance of Method.
12 13 14 15 |
# File 'lib/shomen/model/method.rb', line 12 def initialize(settings={}) super(settings) @table['declarations'] ||= [] end |
Instance Attribute Details
#alias_for ⇒ Object
Aliases.
48 49 50 |
# File 'lib/shomen/model/method.rb', line 48 def alias_for @alias_for end |
#aliases ⇒ Object
Aliases.
45 46 47 |
# File 'lib/shomen/model/method.rb', line 45 def aliases @aliases end |
#comment ⇒ Object
Comment accompanying method definition.
24 25 26 |
# File 'lib/shomen/model/method.rb', line 24 def comment @comment end |
#declarations ⇒ Object
Delarations is a list of keywords that designates characteristics about a method. Common characteristics include ‘reader`, `writer` or `accessor` if the method is defined via an attr method; `public` `private` or `protected` given the methods visibility; and `class` or `instance` given the methods scope. Default designations are are impled if not specifically stated, such as `public` and `instance`.
Using a declarations list simplifies the Shomen data format by allowing declarations to be freely defined, rather than creating a field for each possible designation possible.
42 43 44 |
# File 'lib/shomen/model/method.rb', line 42 def declarations @declarations end |
#dynamic ⇒ Object
Method generated dynamically?
75 76 77 |
# File 'lib/shomen/model/method.rb', line 75 def dynamic @dynamic end |
#file ⇒ Object
Filename.
78 79 80 |
# File 'lib/shomen/model/method.rb', line 78 def file @file end |
#format ⇒ Object
Format of comment (rdoc, markdown or plain).
27 28 29 |
# File 'lib/shomen/model/method.rb', line 27 def format @format end |
#interfaces ⇒ Object
Breakdown of interfaces signature, arguments, parameters, block argument an return values.
52 53 54 |
# File 'lib/shomen/model/method.rb', line 52 def interfaces @interfaces end |
#language ⇒ Object
Source code language.
87 88 89 |
# File 'lib/shomen/model/method.rb', line 87 def language @language end |
#line ⇒ Object
Line number.
81 82 83 |
# File 'lib/shomen/model/method.rb', line 81 def line @line end |
#name ⇒ Object
Method’s name.
18 19 20 |
# File 'lib/shomen/model/method.rb', line 18 def name @name end |
#namespace ⇒ Object Also known as: parent
Method’s namespace.
21 22 23 |
# File 'lib/shomen/model/method.rb', line 21 def namespace @namespace end |
#raises ⇒ Object
List of possible raised errors.
72 73 74 |
# File 'lib/shomen/model/method.rb', line 72 def raises @raises end |
#returns ⇒ Object
List of possible returns types.
69 70 71 |
# File 'lib/shomen/model/method.rb', line 69 def returns @returns end |
#singleton ⇒ Object
Singleton method ‘true` or `false/nil`.
30 31 32 |
# File 'lib/shomen/model/method.rb', line 30 def singleton @singleton end |
#source ⇒ Object
Source code.
84 85 86 |
# File 'lib/shomen/model/method.rb', line 84 def source @source end |
Instance Method Details
#to_h ⇒ Object
94 95 96 97 98 99 |
# File 'lib/shomen/model/method.rb', line 94 def to_h h = super h['!'] = 'method' h['interfaces'] = (interfaces || []).map{ |s| s.to_h } h end |