Class: RBS::Annotate::Annotations::Copy
- Inherits:
-
Object
- Object
- RBS::Annotate::Annotations::Copy
- Defined in:
- lib/rbs/annotate/annotations.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
readonly
Returns the value of attribute annotation.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(annotation:, source:) ⇒ Copy
constructor
A new instance of Copy.
- #method_name ⇒ Object
- #partition ⇒ Object
- #singleton? ⇒ Boolean
- #type_name ⇒ Object
Constructor Details
#initialize(annotation:, source:) ⇒ Copy
Returns a new instance of Copy.
52 53 54 55 |
# File 'lib/rbs/annotate/annotations.rb', line 52 def initialize(annotation:, source:) @annotation = annotation @source = source end |
Instance Attribute Details
#annotation ⇒ Object (readonly)
Returns the value of attribute annotation.
50 51 52 |
# File 'lib/rbs/annotate/annotations.rb', line 50 def annotation @annotation end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
50 51 52 |
# File 'lib/rbs/annotate/annotations.rb', line 50 def source @source end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
82 83 84 85 86 |
# File 'lib/rbs/annotate/annotations.rb', line 82 def ==(other) other.is_a?(Copy) && other.annotation == annotation && other.source == source end |
#hash ⇒ Object
78 79 80 |
# File 'lib/rbs/annotate/annotations.rb', line 78 def hash self.class.hash ^ annotation.hash ^ source.hash end |
#method_name ⇒ Object
62 63 64 65 66 67 |
# File 'lib/rbs/annotate/annotations.rb', line 62 def method_name _, m = partition if m m[1] end end |
#partition ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rbs/annotate/annotations.rb', line 90 def partition case when match = source.match(/(?<constant_name>[^#]+)#(?<method_name>.+)/) [ TypeName(match[:constant_name] || raise), [ false, (match[:method_name] or raise).to_sym ] ] when match = source.match(/(?<constant_name>[^#]+)\.(?<method_name>.+)/) [ TypeName(match[:constant_name] || raise), [ true, (match[:method_name] or raise).to_sym ] ] else [ TypeName(source), nil ] end end |
#singleton? ⇒ Boolean
69 70 71 72 73 74 75 76 |
# File 'lib/rbs/annotate/annotations.rb', line 69 def singleton? _, m = partition if m m[0] else false end end |
#type_name ⇒ Object
57 58 59 60 |
# File 'lib/rbs/annotate/annotations.rb', line 57 def type_name name, _ = partition name end |