Class: Shomen::Model::Method

Inherits:
Abstract show all
Defined in:
lib/shomen/model/method.rb

Direct Known Subclasses

Attribute

Instance Attribute Summary collapse

Attributes inherited from Abstract

#path, #tags

Instance Method Summary collapse

Methods inherited from Abstract

#type

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_forObject

Aliases.



48
49
50
# File 'lib/shomen/model/method.rb', line 48

def alias_for
  @alias_for
end

#aliasesObject

Aliases.



45
46
47
# File 'lib/shomen/model/method.rb', line 45

def aliases
  @aliases
end

#commentObject

Comment accompanying method definition.



24
25
26
# File 'lib/shomen/model/method.rb', line 24

def comment
  @comment
end

#declarationsObject

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

#dynamicObject

Method generated dynamically?



75
76
77
# File 'lib/shomen/model/method.rb', line 75

def dynamic
  @dynamic
end

#fileObject

Filename.



78
79
80
# File 'lib/shomen/model/method.rb', line 78

def file
  @file
end

#formatObject

Format of comment (rdoc, markdown or plain).



27
28
29
# File 'lib/shomen/model/method.rb', line 27

def format
  @format
end

#interfacesObject

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

#languageObject

Source code language.



87
88
89
# File 'lib/shomen/model/method.rb', line 87

def language
  @language
end

#lineObject

Line number.



81
82
83
# File 'lib/shomen/model/method.rb', line 81

def line
  @line
end

#nameObject

Method’s name.



18
19
20
# File 'lib/shomen/model/method.rb', line 18

def name
  @name
end

#namespaceObject Also known as: parent

Method’s namespace.



21
22
23
# File 'lib/shomen/model/method.rb', line 21

def namespace
  @namespace
end

#raisesObject

List of possible raised errors.



72
73
74
# File 'lib/shomen/model/method.rb', line 72

def raises
  @raises
end

#returnsObject

List of possible returns types.



69
70
71
# File 'lib/shomen/model/method.rb', line 69

def returns
  @returns
end

#singletonObject

Singleton method ‘true` or `false/nil`.



30
31
32
# File 'lib/shomen/model/method.rb', line 30

def singleton
  @singleton
end

#sourceObject

Source code.



84
85
86
# File 'lib/shomen/model/method.rb', line 84

def source
  @source
end

Instance Method Details

#to_hObject



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