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.



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

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#klassObject



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

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

#libraryObject



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

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

Class Method Details

.type_idObject



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

def MethodEntry.type_id
  :method
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

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



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

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

#added?Boolean

Returns:

  • (Boolean)


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

def added?
  kind() == :added
end

#constant?Boolean

Returns:

  • (Boolean)


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

def constant?
  typename() == :constant
end

#defined?Boolean

Returns:

  • (Boolean)


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

def defined?
  kind() == :defined
end

#descriptionObject



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

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

#hashObject



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

def hash
  @id.hash
end

#index_idObject



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

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

#inspectObject



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

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

#instance_method?Boolean

Returns:

  • (Boolean)


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

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

#labelObject



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

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

#labelsObject



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

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

#nameObject



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

def name
  methodid2mname(@id)
end

#name?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#name_match?(re) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#private?Boolean

Returns:

  • (Boolean)


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

def private?
  visibility() == :private
end

#private_instance_method?Boolean

Returns:

  • (Boolean)


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

def private_instance_method?
  instance_method? and public?
end

#private_singleton_method?Boolean

Returns:

  • (Boolean)


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

def private_singleton_method?
  singleton_method? and private?
end

#protected?Boolean

Returns:

  • (Boolean)


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

def protected?
  visibility() == :protected
end

#public?Boolean

Returns:

  • (Boolean)


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

def public?
  visibility() != :private
end

#public_instance_method?Boolean

Returns:

  • (Boolean)


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

def public_instance_method?
  instance_method? and public?
end

#public_singleton_method?Boolean

Returns:

  • (Boolean)


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

def public_singleton_method?
  singleton_method? and public?
end

#really_public?Boolean

Returns:

  • (Boolean)


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

def really_public?
  visibility() == :public
end

#redefined?Boolean

Returns:

  • (Boolean)


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

def redefined?
  kind() == :redefined
end

#short_labelObject



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

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

#singleton_method?Boolean

Returns:

  • (Boolean)


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

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

#sort_keyObject



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

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

#specObject



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

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

#spec_stringObject



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

def spec_string
  methodid2specstring(@id)
end

#special_variable?Boolean

Returns:

  • (Boolean)


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

def special_variable?
  typename() == :special_variable
end

#type_labelObject



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

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



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

def typechar
  methodid2typechar(@id)
end

#typemarkObject



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

def typemark
  methodid2typemark(@id)
end

#typenameObject Also known as: type

typename = :singleton_method

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


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

def typename
  methodid2typename(@id)
end