Class: BitClust::MethodNamePattern

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(c = nil, t = nil, m = nil, lib = nil) ⇒ MethodNamePattern

Returns a new instance of MethodNamePattern.


148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/bitclust/methodid.rb', line 148

def initialize(c = nil, t = nil, m = nil, lib = nil)
  @klass = c
  if c and c.empty?
    @klass = nil
  end
  @type = t
  @method = m
  if m and m.empty?
    @method = nil
  end
  @library = library
  @crecache = []
  @mrecache = []
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass


163
164
165
# File 'lib/bitclust/methodid.rb', line 163

def klass
  @klass
end

#libraryObject (readonly)

Returns the value of attribute library


166
167
168
# File 'lib/bitclust/methodid.rb', line 166

def library
  @library
end

#methodObject (readonly)

Returns the value of attribute method


165
166
167
# File 'lib/bitclust/methodid.rb', line 165

def method
  @method
end

#typeObject (readonly)

Returns the value of attribute type


164
165
166
# File 'lib/bitclust/methodid.rb', line 164

def type
  @type
end

Instance Method Details

#class?Boolean

Returns:

  • (Boolean)

198
199
200
# File 'lib/bitclust/methodid.rb', line 198

def class?
  @klass and (not @type and not @method)
end

#empty?Boolean

Returns:

  • (Boolean)

194
195
196
# File 'lib/bitclust/methodid.rb', line 194

def empty?
  not @klass and not @type and not @method
end

#inspectObject


168
169
170
# File 'lib/bitclust/methodid.rb', line 168

def inspect
  "#<pattern #{esc(@library)}.#{esc(@klass)}#{tesc(@type)}#{esc(@method)}>"
end

#match?(m) ⇒ Boolean

Returns:

  • (Boolean)

182
183
184
185
186
187
# File 'lib/bitclust/methodid.rb', line 182

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

#method?Boolean

Returns:

  • (Boolean)

202
203
204
# File 'lib/bitclust/methodid.rb', line 202

def method?
  @method or (@type and @type != '$')
end

#select_classes(cs) ⇒ Object


189
190
191
192
# File 'lib/bitclust/methodid.rb', line 189

def select_classes(cs)
  return cs unless @klass
  expand_ic(cs, @klass, @crecache)
end

#special_variable?Boolean

Returns:

  • (Boolean)

206
207
208
# File 'lib/bitclust/methodid.rb', line 206

def special_variable?
  @type == '$'
end