Class: BitClust::MethodEntry

Inherits:
Entry show all
Defined in:
lib/bitclust/methodentry.rb

Overview

Entry for methods(instance methods/singleton methods/module_functions), constants and special variables(like $!).

Constant Summary collapse

KIND_NUM =
{:defined => 0, :redefined => 1, :added => 2}

Constants included from NameUtils

NameUtils::CHAR_TO_MARK, NameUtils::CHAR_TO_NAME, NameUtils::CLASS_NAME_RE, NameUtils::CLASS_PATH_RE, NameUtils::CONST_PATH_RE, NameUtils::CONST_RE, NameUtils::GVAR_RE, NameUtils::LIBNAME_RE, NameUtils::MARK_TO_CHAR, NameUtils::MARK_TO_NAME, NameUtils::METHOD_NAME_RE, NameUtils::METHOD_SPEC_RE, NameUtils::MID, NameUtils::NAME_TO_CHAR, NameUtils::NAME_TO_MARK, NameUtils::TYPEMARK_RE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entry

#detail_source, #encoding, #loaded?, persistent_properties, property, #save, #synopsis_source, #type_id

Methods included from NameUtils

build_method_id, classid2name, classname2id, classname?, decodeid, decodename_fs, decodename_url, encodeid, encodename_fs, encodename_rdocurl, encodename_url, functionname?, gvarname?, html_filename, libid2name, libname2id, libname?, method_spec?, methodid2classid, methodid2libid, methodid2mname, methodid2specparts, methodid2specstring, methodid2typechar, methodid2typemark, methodid2typename, methodname?, split_method_id, split_method_spec, typechar2mark, typechar2name, typechar?, typemark2char, typemark2name, typemark?, typename2char, typename2mark, typename?

Constructor Details

#initialize(db, id) ⇒ MethodEntry

Returns a new instance of MethodEntry.



24
25
26
27
28
# File 'lib/bitclust/methodentry.rb', line 24

def initialize(db, id)
  super db
  @id = id
  init_properties
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



30
31
32
# File 'lib/bitclust/methodentry.rb', line 30

def id
  @id
end

#klassObject



92
93
94
# File 'lib/bitclust/methodentry.rb', line 92

def klass
  @klass ||= @db.fetch_class_id(methodid2classid(@id))
end

#libraryObject



86
87
88
# File 'lib/bitclust/methodentry.rb', line 86

def library
  @library ||= @db.fetch_library_id(methodid2libid(@id))
end

Class Method Details

.type_idObject



20
21
22
# File 'lib/bitclust/methodentry.rb', line 20

def MethodEntry.type_id
  :method
end

Instance Method Details

#<=>(other) ⇒ Object



43
44
45
# File 'lib/bitclust/methodentry.rb', line 43

def <=>(other)
  sort_key() <=> other.sort_key
end

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



32
33
34
35
# File 'lib/bitclust/methodentry.rb', line 32

def ==(other)
  return false if self.class != other.class
  @id == other.id
end

#added?Boolean

Returns:

  • (Boolean)


200
201
202
# File 'lib/bitclust/methodentry.rb', line 200

def added?
  kind() == :added
end

#constant?Boolean

Returns:

  • (Boolean)


188
189
190
# File 'lib/bitclust/methodentry.rb', line 188

def constant?
  typename() == :constant
end

#defined?Boolean

Returns:

  • (Boolean)


196
197
198
# File 'lib/bitclust/methodentry.rb', line 196

def defined?
  kind() == :defined
end

#descriptionObject



212
213
214
# File 'lib/bitclust/methodentry.rb', line 212

def description
  source.split(/\n\n+/, 3)[1]
end

#hashObject



39
40
41
# File 'lib/bitclust/methodentry.rb', line 39

def hash
  @id.hash
end

#index_idObject



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

def index_id
  "#{methodid2typechar(@id)}_#{encodename_fs(name).gsub(/=/, '--')}".upcase
end

#inspectObject



106
107
108
109
# File 'lib/bitclust/methodentry.rb', line 106

def inspect
  c, t, _m, _lib = methodid2specparts(@id)
  "\#<method #{c}#{t}#{names().join(',')}>"
end

#instance_method?Boolean

Returns:

  • (Boolean)


183
184
185
186
# File 'lib/bitclust/methodentry.rb', line 183

def instance_method?
  t = typename()
  t == :instance_method or t == :module_function
end

#labelObject



119
120
121
122
# File 'lib/bitclust/methodentry.rb', line 119

def label
  c, t, m, _lib = methodid2specparts(@id)
  "#{t == '$' ? '' : c}#{t}#{m}"
end

#labelsObject



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

def labels
  c, t, _m, _lib = methodid2specparts(@id)
  names().map {|name| "#{c}#{t}#{name}" }
end

#nameObject



53
54
55
# File 'lib/bitclust/methodentry.rb', line 53

def name
  methodid2mname(@id)
end

#name?(name) ⇒ Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/bitclust/methodentry.rb', line 138

def name?(name)
  names().include?(name)
end

#name_match?(re) ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/bitclust/methodentry.rb', line 142

def name_match?(re)
  names().any? {|n| re =~ n }
end

#private?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/bitclust/methodentry.rb', line 158

def private?
  visibility() == :private
end

#private_instance_method?Boolean

Returns:

  • (Boolean)


174
175
176
# File 'lib/bitclust/methodentry.rb', line 174

def private_instance_method?
  instance_method? and public?
end

#private_singleton_method?Boolean

Returns:

  • (Boolean)


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

def private_singleton_method?
  singleton_method? and private?
end

#protected?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/bitclust/methodentry.rb', line 154

def protected?
  visibility() == :protected
end

#public?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/bitclust/methodentry.rb', line 150

def public?
  visibility() != :private
end

#public_instance_method?Boolean

Returns:

  • (Boolean)


170
171
172
# File 'lib/bitclust/methodentry.rb', line 170

def public_instance_method?
  instance_method? and public?
end

#public_singleton_method?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/bitclust/methodentry.rb', line 162

def public_singleton_method?
  singleton_method? and public?
end

#really_public?Boolean

Returns:

  • (Boolean)


146
147
148
# File 'lib/bitclust/methodentry.rb', line 146

def really_public?
  visibility() == :public
end

#redefined?Boolean

Returns:

  • (Boolean)


204
205
206
# File 'lib/bitclust/methodentry.rb', line 204

def redefined?
  kind() == :redefined
end

#short_labelObject



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

def short_label
  _c, t, m, _lib = methodid2specparts(@id)
  "#{t == '#' ? '' : t}#{m}"
end

#singleton_method?Boolean

Returns:

  • (Boolean)


178
179
180
181
# File 'lib/bitclust/methodentry.rb', line 178

def singleton_method?
  t = typename()
  t == :singleton_method or t == :module_function
end

#sort_keyObject



49
50
51
# File 'lib/bitclust/methodentry.rb', line 49

def sort_key
  [label(), KIND_NUM[kind()]]
end

#specObject



111
112
113
# File 'lib/bitclust/methodentry.rb', line 111

def spec
  MethodSpec.new(*methodid2specparts(@id))
end

#spec_stringObject



115
116
117
# File 'lib/bitclust/methodentry.rb', line 115

def spec_string
  methodid2specstring(@id)
end

#special_variable?Boolean

Returns:

  • (Boolean)


192
193
194
# File 'lib/bitclust/methodentry.rb', line 192

def special_variable?
  typename() == :special_variable
end

#type_labelObject



76
77
78
79
80
81
82
83
84
# File 'lib/bitclust/methodentry.rb', line 76

def type_label
  case typemark()
  when '.'  then 'singleton method'
  when '#'  then 'instance method'
  when '.#' then 'module function'
  when '::' then 'constant'
  when '$'  then 'variable'
  end
end

#typecharObject



72
73
74
# File 'lib/bitclust/methodentry.rb', line 72

def typechar
  methodid2typechar(@id)
end

#typemarkObject



68
69
70
# File 'lib/bitclust/methodentry.rb', line 68

def typemark
  methodid2typemark(@id)
end

#typenameObject Also known as: type

typename = :singleton_method

| :instance_method
| :module_function
| :constant
| :special_variable


62
63
64
# File 'lib/bitclust/methodentry.rb', line 62

def typename
  methodid2typename(@id)
end

#undefined?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'lib/bitclust/methodentry.rb', line 208

def undefined?
  kind() == :undefined
end