Class: ApiDiff::Function
- Inherits:
-
Object
- Object
- ApiDiff::Function
- Defined in:
- lib/api_diff/function.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #full_signature ⇒ Object
- #hash ⇒ Object
-
#initialize(name:, signature:, return_type:, static:, constructor:) ⇒ Function
constructor
A new instance of Function.
- #is_constructor? ⇒ Boolean
- #is_static? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name:, signature:, return_type:, static:, constructor:) ⇒ Function
Returns a new instance of Function.
5 6 7 8 9 10 11 |
# File 'lib/api_diff/function.rb', line 5 def initialize(name:, signature:, return_type:, static:, constructor:) @name = name @signature = signature @return_type = return_type @static = static @constructor = constructor end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/api_diff/function.rb', line 3 def name @name end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
3 4 5 |
# File 'lib/api_diff/function.rb', line 3 def return_type @return_type end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
3 4 5 |
# File 'lib/api_diff/function.rb', line 3 def signature @signature end |
Instance Method Details
#<=>(other) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/api_diff/function.rb', line 41 def <=>(other) # static at the bottom return 1 if is_static? and not other.is_static? return -1 if not is_static? and other.is_static? # constructors first return -1 if is_constructor? and not other.is_constructor? return 1 if not is_constructor? and other.is_constructor? if is_constructor? # sort constructors by length [full_signature.size, full_signature] <=> [other.full_signature.size, other.full_signature] else [name, full_signature] <=> [other.name, other.full_signature] end end |
#eql?(other) ⇒ Boolean
37 38 39 |
# File 'lib/api_diff/function.rb', line 37 def eql?(other) full_signature == other.full_signature end |
#full_signature ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/api_diff/function.rb', line 25 def full_signature if return_type.nil? signature else "#{signature} -> #{return_type}" end end |
#hash ⇒ Object
33 34 35 |
# File 'lib/api_diff/function.rb', line 33 def hash full_signature.hash end |
#is_constructor? ⇒ Boolean
13 14 15 |
# File 'lib/api_diff/function.rb', line 13 def is_constructor? @constructor end |
#is_static? ⇒ Boolean
17 18 19 |
# File 'lib/api_diff/function.rb', line 17 def is_static? @static end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/api_diff/function.rb', line 21 def to_s full_signature end |