Class: BitClust::MethodEntry
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,
:undefined => 3, :nomethod => 4}
Constants inherited
from Entry
Entry::BracketLink
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
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, display_typemark, 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
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
Returns the value of attribute id.
30
31
32
|
# File 'lib/bitclust/methodentry.rb', line 30
def id
@id
end
|
102
103
104
|
# File 'lib/bitclust/methodentry.rb', line 102
def klass
@klass ||= @db.fetch_class_id(methodid2classid(@id))
end
|
96
97
98
|
# File 'lib/bitclust/methodentry.rb', line 96
def library
@library ||= @db.fetch_library_id(methodid2libid(@id))
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
309
310
311
|
# File 'lib/bitclust/methodentry.rb', line 309
def added?
kind() == :added
end
|
#constant? ⇒ Boolean
297
298
299
|
# File 'lib/bitclust/methodentry.rb', line 297
def constant?
typename() == :constant
end
|
#defined? ⇒ Boolean
305
306
307
|
# File 'lib/bitclust/methodentry.rb', line 305
def defined?
kind() == :defined
end
|
#description ⇒ Object
327
328
329
330
331
332
|
# File 'lib/bitclust/methodentry.rb', line 327
def description
paragraphs = source.split(/\n\n+/).drop(1)
para = paragraphs.find {|p| !p.start_with?('@', '{:') } || paragraphs.first || ''
description_text(para)
end
|
#display_label ⇒ Object
bitclust#250: label の表示専用版(module function は 4.0 以降 "?." で
表示)。label 自身は refsdatabase.rb の [[a:...]] アンカーキーや
bitclust methods --diff の突き合わせが literal ".#" 前提で使うので
変えない -- テンプレート側の実際の表示箇所だけがこちらを呼ぶ
146
147
148
149
|
# File 'lib/bitclust/methodentry.rb', line 146
def display_label
c, t, m, _lib = methodid2specparts(@id)
"#{t == '$' ? '' : c}#{display_typemark}#{m}"
end
|
#display_short_label ⇒ Object
bitclust#250: short_label の表示専用版。short_label 自身の唯一の
呼び出し元(htmlutils.rb の link_to_method)は display_short_label に
切り替え済みだが、short_label 自体は同じ理由(識別子的な使い方をする
将来のコードのため)で変えない
160
161
162
163
|
# File 'lib/bitclust/methodentry.rb', line 160
def display_short_label
_c, t, m, _lib = methodid2specparts(@id)
"#{t == '#' ? '' : display_typemark}#{m}"
end
|
#display_title_labels ⇒ Object
bitclust#250: title_labels の表示専用版(
タグ・見出しで使う)
184
185
186
187
|
# File 'lib/bitclust/methodentry.rb', line 184
def display_title_labels
c, t, _m, _lib = methodid2specparts(@id)
names().map {|name| "#{t == '$' ? '' : c}#{display_typemark}#{name}" }
end
|
#display_typemark ⇒ Object
bitclust#250: 表示専用の typemark。DB のバージョンが 4.0 以降なら
module function の "." を "?." にする(それ以外の typemark は不変)。
typemark 自体(識別子として使う方)は変えない -- URL・spec 文字列・
refsdatabase のアンカーキー等はすべて typemark() 経由のまま
81
82
83
|
# File 'lib/bitclust/methodentry.rb', line 81
def display_typemark
NameUtils.display_typemark(typemark(), @db.propget('version'))
end
|
#fill_since(name, version) ⇒ Object
name の since が未設定の場合のみ version を追加する。追加したら true、
既に値があって何もしなければ false を返す
214
215
216
|
# File 'lib/bitclust/methodentry.rb', line 214
def fill_since(name, version)
fill_version_token(:since_by_name, :since_of, name, version)
end
|
#fill_until(name, version) ⇒ Object
219
220
221
|
# File 'lib/bitclust/methodentry.rb', line 219
def fill_until(name, version)
fill_version_token(:until_by_name, :until_of, name, version)
end
|
39
40
41
|
# File 'lib/bitclust/methodentry.rb', line 39
def hash
@id.hash
end
|
165
166
167
|
# File 'lib/bitclust/methodentry.rb', line 165
def index_id
"#{methodid2typechar(@id)}_#{encodename_fs(name).gsub(/=/, '--')}".upcase
end
|
123
124
125
126
|
# File 'lib/bitclust/methodentry.rb', line 123
def inspect
c, t, _m, _lib = methodid2specparts(@id)
"\#<method #{c}#{t}#{names().join(',')}>"
end
|
#instance_method? ⇒ Boolean
292
293
294
295
|
# File 'lib/bitclust/methodentry.rb', line 292
def instance_method?
t = typename()
t == :instance_method or t == :module_function
end
|
137
138
139
140
|
# File 'lib/bitclust/methodentry.rb', line 137
def label
c, t, m, _lib = methodid2specparts(@id)
"#{t == '$' ? '' : c}#{t}#{m}"
end
|
169
170
171
172
|
# File 'lib/bitclust/methodentry.rb', line 169
def labels
c, t, _m, _lib = methodid2specparts(@id)
names().map {|name| "#{c}#{t}#{name}" }
end
|
54
55
56
|
# File 'lib/bitclust/methodentry.rb', line 54
def name
methodid2mname(@id)
end
|
#name?(name) ⇒ Boolean
189
190
191
|
# File 'lib/bitclust/methodentry.rb', line 189
def name?(name)
names().include?(name)
end
|
#name_match?(re) ⇒ Boolean
247
248
249
|
# File 'lib/bitclust/methodentry.rb', line 247
def name_match?(re)
names().any? {|n| re =~ n }
end
|
#nomethod? ⇒ Boolean
説明のためだけに記載されていて実際には定義されていないメソッド
(ソースの @nomethod メタデータ行で指定する)
323
324
325
|
# File 'lib/bitclust/methodentry.rb', line 323
def nomethod?
kind() == :nomethod
end
|
#private? ⇒ Boolean
263
264
265
|
# File 'lib/bitclust/methodentry.rb', line 263
def private?
visibility() == :private
end
|
#private_instance_method? ⇒ Boolean
279
280
281
|
# File 'lib/bitclust/methodentry.rb', line 279
def private_instance_method?
instance_method? and private?
end
|
#private_singleton_method? ⇒ Boolean
271
272
273
|
# File 'lib/bitclust/methodentry.rb', line 271
def private_singleton_method?
singleton_method? and private?
end
|
#protected? ⇒ Boolean
259
260
261
|
# File 'lib/bitclust/methodentry.rb', line 259
def protected?
visibility() == :protected
end
|
#protected_instance_method? ⇒ Boolean
283
284
285
|
# File 'lib/bitclust/methodentry.rb', line 283
def protected_instance_method?
instance_method? and protected?
end
|
#public? ⇒ Boolean
255
256
257
|
# File 'lib/bitclust/methodentry.rb', line 255
def public?
visibility() != :private && visibility() != :protected
end
|
#public_instance_method? ⇒ Boolean
275
276
277
|
# File 'lib/bitclust/methodentry.rb', line 275
def public_instance_method?
instance_method? and public?
end
|
#public_singleton_method? ⇒ Boolean
267
268
269
|
# File 'lib/bitclust/methodentry.rb', line 267
def public_singleton_method?
singleton_method? and public?
end
|
#really_public? ⇒ Boolean
251
252
253
|
# File 'lib/bitclust/methodentry.rb', line 251
def really_public?
visibility() == :public
end
|
#redefined? ⇒ Boolean
313
314
315
|
# File 'lib/bitclust/methodentry.rb', line 313
def redefined?
kind() == :redefined
end
|
#short_label ⇒ Object
151
152
153
154
|
# File 'lib/bitclust/methodentry.rb', line 151
def short_label
_c, t, m, _lib = methodid2specparts(@id)
"#{t == '#' ? '' : t}#{m}"
end
|
#since_map ⇒ Object
204
205
206
|
# File 'lib/bitclust/methodentry.rb', line 204
def since_map
decode_version_tokens(since_by_name)
end
|
#since_of(name) ⇒ Object
名前別 since/until(bitclust#132)。名前ごとに別バージョンで
追加/削除されうる別名(例: alias)を区別して記録する
196
197
198
|
# File 'lib/bitclust/methodentry.rb', line 196
def since_of(name)
since_map[name]
end
|
#singleton_method? ⇒ Boolean
287
288
289
290
|
# File 'lib/bitclust/methodentry.rb', line 287
def singleton_method?
t = typename()
t == :singleton_method or t == :module_function
end
|
50
51
52
|
# File 'lib/bitclust/methodentry.rb', line 50
def sort_key
[label(), KIND_NUM[kind()]]
end
|
128
129
130
131
|
# File 'lib/bitclust/methodentry.rb', line 128
def spec
c, t, m, lib = methodid2specparts(@id)
MethodSpec.new(c, t, m, lib)
end
|
#spec_string ⇒ Object
133
134
135
|
# File 'lib/bitclust/methodentry.rb', line 133
def spec_string
methodid2specstring(@id)
end
|
#special_variable? ⇒ Boolean
301
302
303
|
# File 'lib/bitclust/methodentry.rb', line 301
def special_variable?
typename() == :special_variable
end
|
#title_labels ⇒ Object
Every name of this entry, formatted the same way as #label (i.e.
without the redundant class prefix on special variables such as $!,
unlike #labels). Used where all aliases of a method need to be listed
together, e.g. the
of its page.
178
179
180
181
|
# File 'lib/bitclust/methodentry.rb', line 178
def title_labels
c, t, _m, _lib = methodid2specparts(@id)
names().map {|name| "#{t == '$' ? '' : c}#{t}#{name}" }
end
|
#type_label ⇒ Object
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/bitclust/methodentry.rb', line 85
def type_label
case typemark()
when '.' then 'singleton method'
when '#' then 'instance method'
when '.#' then 'module function'
when '::' then 'constant'
when '$' then 'variable'
else raise "invalid typemark: #{typemark().inspect}"
end
end
|
73
74
75
|
# File 'lib/bitclust/methodentry.rb', line 73
def typechar
methodid2typechar(@id)
end
|
69
70
71
|
# File 'lib/bitclust/methodentry.rb', line 69
def typemark
methodid2typemark(@id)
end
|
#typename ⇒ Object
Also known as:
type
typename = :singleton_method
| :instance_method
| :module_function
| :constant
| :special_variable
63
64
65
|
# File 'lib/bitclust/methodentry.rb', line 63
def typename
methodid2typename(@id)
end
|
#undefined? ⇒ Boolean
317
318
319
|
# File 'lib/bitclust/methodentry.rb', line 317
def undefined?
kind() == :undefined
end
|
#until_map ⇒ Object
208
209
210
|
# File 'lib/bitclust/methodentry.rb', line 208
def until_map
decode_version_tokens(until_by_name)
end
|
#until_of(name) ⇒ Object
200
201
202
|
# File 'lib/bitclust/methodentry.rb', line 200
def until_of(name)
until_map[name]
end
|