Class: BitClust::MethodSpec

Inherits:
Object show all
Defined in:
lib/bitclust/methodid.rb

Overview

A MethodSpec has #klass, #type, #method and #library. All attributes are string. #library is optional.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(c, t, m, library = nil) ⇒ MethodSpec

Returns a new instance of MethodSpec.



71
72
73
74
75
76
# File 'lib/bitclust/methodid.rb', line 71

def initialize(c, t, m, library = nil)
  @klass = c
  @type = t
  @method = m
  @library = library
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



78
79
80
# File 'lib/bitclust/methodid.rb', line 78

def klass
  @klass
end

#libraryObject (readonly)

Returns the value of attribute library.



81
82
83
# File 'lib/bitclust/methodid.rb', line 81

def library
  @library
end

#methodObject (readonly)

Returns the value of attribute method.



80
81
82
# File 'lib/bitclust/methodid.rb', line 80

def method
  @method
end

#typeObject (readonly)

Returns the value of attribute type.



79
80
81
# File 'lib/bitclust/methodid.rb', line 79

def type
  @type
end

Class Method Details

.parse(str) ⇒ Object



67
68
69
# File 'lib/bitclust/methodid.rb', line 67

def MethodSpec.parse(str)
  new(*NameUtils.split_method_spec(str))
end

Instance Method Details

#<=>(other) ⇒ Object



108
109
110
# File 'lib/bitclust/methodid.rb', line 108

def <=>(other)
  [@klass, @type, @method] <=> [other.klass, other.type, other.method]
end

#==(other) ⇒ Object Also known as: eql?



95
96
97
98
99
100
# File 'lib/bitclust/methodid.rb', line 95

def ==(other)
  return false if self.class != other.class
  @klass == other.klass and
  @type == other.type and
  @method == other.method
end

#constant?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/bitclust/methodid.rb', line 133

def constant?
  @type == '::'
end

#display_nameObject



91
92
93
# File 'lib/bitclust/methodid.rb', line 91

def display_name
  @type == '$' ? "$#{@method}" : to_s()
end

#hashObject



104
105
106
# File 'lib/bitclust/methodid.rb', line 104

def hash
  to_s().hash
end

#inspectObject



83
84
85
# File 'lib/bitclust/methodid.rb', line 83

def inspect
  "#<spec #{@klass}#{@type}#{@method}>"
end

#instance_method?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/bitclust/methodid.rb', line 121

def instance_method?
  @type == '#' or @type == '.#'
end

#match?(m) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
115
# File 'lib/bitclust/methodid.rb', line 112

def match?(m)
  (not @type or @type == m.typemark) and
  (not @method or m.name?(@method))
end

#method?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/bitclust/methodid.rb', line 129

def method?
  singleton_method? or instance_method?
end

#module_function?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/bitclust/methodid.rb', line 125

def module_function?
  @type == '.#'
end

#singleton_method?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/bitclust/methodid.rb', line 117

def singleton_method?
  @type == '.' or @type == '.#'
end

#special_variable?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/bitclust/methodid.rb', line 137

def special_variable?
  @type == '$'
end

#to_sObject



87
88
89
# File 'lib/bitclust/methodid.rb', line 87

def to_s
  "#{@klass}#{@type}#{@method}"
end