Class: BitClust::MethodSpec
Overview
A MethodSpec has #klass, #type, #method and #library. All attributes are string. #library is optional.
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#library ⇒ Object
readonly
Returns the value of attribute library.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #constant? ⇒ Boolean
- #display_name ⇒ Object
- #hash ⇒ Object
-
#initialize(c, t, m, library = nil) ⇒ MethodSpec
constructor
A new instance of MethodSpec.
- #inspect ⇒ Object
- #instance_method? ⇒ Boolean
- #match?(m) ⇒ Boolean
- #method? ⇒ Boolean
- #module_function? ⇒ Boolean
- #singleton_method? ⇒ Boolean
- #special_variable? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(c, t, m, library = nil) ⇒ MethodSpec
Returns a new instance of MethodSpec.
72 73 74 75 76 77 |
# File 'lib/bitclust/methodid.rb', line 72 def initialize(c, t, m, library = nil) @klass = c @type = t @method = m @library = library end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
79 80 81 |
# File 'lib/bitclust/methodid.rb', line 79 def klass @klass end |
#library ⇒ Object (readonly)
Returns the value of attribute library.
82 83 84 |
# File 'lib/bitclust/methodid.rb', line 82 def library @library end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
81 82 83 |
# File 'lib/bitclust/methodid.rb', line 81 def method @method end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
80 81 82 |
# File 'lib/bitclust/methodid.rb', line 80 def type @type end |
Class Method Details
.parse(str) ⇒ Object
68 69 70 |
# File 'lib/bitclust/methodid.rb', line 68 def MethodSpec.parse(str) new(*NameUtils.split_method_spec(str)) end |
Instance Method Details
#<=>(other) ⇒ Object
109 110 111 |
# File 'lib/bitclust/methodid.rb', line 109 def <=>(other) [@klass, @type, @method] <=> [other.klass, other.type, other.method] end |
#==(other) ⇒ Object Also known as: eql?
96 97 98 99 100 101 |
# File 'lib/bitclust/methodid.rb', line 96 def ==(other) return false if self.class != other.class @klass == other.klass and @type == other.type and @method == other.method end |
#constant? ⇒ Boolean
134 135 136 |
# File 'lib/bitclust/methodid.rb', line 134 def constant? @type == '::' end |
#display_name ⇒ Object
92 93 94 |
# File 'lib/bitclust/methodid.rb', line 92 def display_name @type == '$' ? "$#{@method}" : to_s() end |
#hash ⇒ Object
105 106 107 |
# File 'lib/bitclust/methodid.rb', line 105 def hash to_s().hash end |
#inspect ⇒ Object
84 85 86 |
# File 'lib/bitclust/methodid.rb', line 84 def inspect "#<spec #{@klass}#{@type}#{@method}>" end |
#instance_method? ⇒ Boolean
122 123 124 |
# File 'lib/bitclust/methodid.rb', line 122 def instance_method? @type == '#' or @type == '.#' end |
#match?(m) ⇒ Boolean
113 114 115 116 |
# File 'lib/bitclust/methodid.rb', line 113 def match?(m) (not @type or @type == m.typemark) and (not @method or m.name?(@method)) end |
#method? ⇒ Boolean
130 131 132 |
# File 'lib/bitclust/methodid.rb', line 130 def method? singleton_method? or instance_method? end |
#module_function? ⇒ Boolean
126 127 128 |
# File 'lib/bitclust/methodid.rb', line 126 def module_function? @type == '.#' end |
#singleton_method? ⇒ Boolean
118 119 120 |
# File 'lib/bitclust/methodid.rb', line 118 def singleton_method? @type == '.' or @type == '.#' end |
#special_variable? ⇒ Boolean
138 139 140 |
# File 'lib/bitclust/methodid.rb', line 138 def special_variable? @type == '$' end |
#to_s ⇒ Object
88 89 90 |
# File 'lib/bitclust/methodid.rb', line 88 def to_s "#{@klass}#{@type}#{@method}" end |