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


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

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

#libraryObject


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

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


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

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

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


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

def ==(other)
  @id == other.id
end

#added?Boolean

Returns:

  • (Boolean)

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

def added?
  kind() == :added
end

#constant?Boolean

Returns:

  • (Boolean)

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

def constant?
  typename() == :constant
end

#defined?Boolean

Returns:

  • (Boolean)

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

def defined?
  kind() == :defined
end

#hashObject


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

def hash
  @id.hash
end

#index_idObject


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

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

#inspectObject


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

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

#instance_method?Boolean

Returns:

  • (Boolean)

180
181
182
183
# File 'lib/bitclust/methodentry.rb', line 180

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

#labelObject


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

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

#labelsObject


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

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

#nameObject


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

def name
  methodid2mname(@id)
end

#name?(name) ⇒ Boolean

Returns:

  • (Boolean)

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

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

#name_match?(re) ⇒ Boolean

Returns:

  • (Boolean)

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

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

#private?Boolean

Returns:

  • (Boolean)

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

def private?
  visibility() == :private
end

#private_instance_method?Boolean

Returns:

  • (Boolean)

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

def private_instance_method?
  instance_method? and public?
end

#private_singleton_method?Boolean

Returns:

  • (Boolean)

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

def private_singleton_method?
  singleton_method? and private?
end

#protected?Boolean

Returns:

  • (Boolean)

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

def protected?
  visibility() == :protected
end

#public?Boolean

Returns:

  • (Boolean)

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

def public?
  visibility() != :private
end

#public_instance_method?Boolean

Returns:

  • (Boolean)

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

def public_instance_method?
  instance_method? and public?
end

#public_singleton_method?Boolean

Returns:

  • (Boolean)

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

def public_singleton_method?
  singleton_method? and public?
end

#really_public?Boolean

Returns:

  • (Boolean)

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

def really_public?
  visibility() == :public
end

#redefined?Boolean

Returns:

  • (Boolean)

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

def redefined?
  kind() == :redefined
end

#short_labelObject


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

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

#singleton_method?Boolean

Returns:

  • (Boolean)

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

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

#sort_keyObject


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

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

#specObject


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

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

#spec_stringObject


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

def spec_string
  methodid2specstring(@id)
end

#special_variable?Boolean

Returns:

  • (Boolean)

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

def special_variable?
  typename() == :special_variable
end

#type_labelObject


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

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


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

def typechar
  methodid2typechar(@id)
end

#typemarkObject


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

def typemark
  methodid2typemark(@id)
end

#typenameObject Also known as: type

typename = :singleton_method

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

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

def typename
  methodid2typename(@id)
end