Class: NeuronCheckSystem::Declaration
- Inherits:
-
Object
- Object
- NeuronCheckSystem::Declaration
- Defined in:
- lib/neuroncheck/declaration.rb
Instance Attribute Summary collapse
-
#arg_matchers ⇒ Object
Returns the value of attribute arg_matchers.
-
#assigned_attribute_name ⇒ Object
Returns the value of attribute assigned_attribute_name.
-
#assigned_class_or_module ⇒ Object
Returns the value of attribute assigned_class_or_module.
-
#assigned_method ⇒ Object
Returns the value of attribute assigned_method.
-
#assigned_singleton_original_class ⇒ Object
Returns the value of attribute assigned_singleton_original_class.
-
#attr_matcher ⇒ Object
Returns the value of attribute attr_matcher.
-
#declared_caller_locations ⇒ Object
Returns the value of attribute declared_caller_locations.
-
#postcond ⇒ Object
Returns the value of attribute postcond.
-
#postcond_allow_instance_method ⇒ Object
Returns the value of attribute postcond_allow_instance_method.
-
#precond ⇒ Object
Returns the value of attribute precond.
-
#precond_allow_instance_method ⇒ Object
Returns the value of attribute precond_allow_instance_method.
-
#return_matcher ⇒ Object
Returns the value of attribute return_matcher.
-
#shorthand ⇒ Object
Returns the value of attribute shorthand.
Instance Method Summary collapse
- #assinged_to_singleton_method? ⇒ Boolean
- #assinged_to_toplevel_method? ⇒ Boolean
- #attribute? ⇒ Boolean
-
#initialize ⇒ Declaration
constructor
A new instance of Declaration.
- #meta_info_as_json ⇒ Object
-
#signature_caption ⇒ Object
メソッド名/属性名+引数+戻り値の表記文字列を取得.
-
#signature_caption_name_only ⇒ Object
メソッド名/属性名の表記文字列を取得.
Constructor Details
#initialize ⇒ Declaration
Returns a new instance of Declaration.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/neuroncheck/declaration.rb', line 169 def initialize @arg_matchers = [] @return_matcher = nil @attr_matcher = nil @precond = nil @precond_allow_instance_method = false @postcond = nil @postcond_allow_instance_method = false @assigned_class_or_module = nil @assigned_method = nil @assigned_singleton_original_class = nil @assigned_attribute_name = nil @shorthand = false @declared_caller_locations = nil end |
Instance Attribute Details
#arg_matchers ⇒ Object
Returns the value of attribute arg_matchers.
152 153 154 |
# File 'lib/neuroncheck/declaration.rb', line 152 def arg_matchers @arg_matchers end |
#assigned_attribute_name ⇒ Object
Returns the value of attribute assigned_attribute_name.
164 165 166 |
# File 'lib/neuroncheck/declaration.rb', line 164 def assigned_attribute_name @assigned_attribute_name end |
#assigned_class_or_module ⇒ Object
Returns the value of attribute assigned_class_or_module.
161 162 163 |
# File 'lib/neuroncheck/declaration.rb', line 161 def assigned_class_or_module @assigned_class_or_module end |
#assigned_method ⇒ Object
Returns the value of attribute assigned_method.
162 163 164 |
# File 'lib/neuroncheck/declaration.rb', line 162 def assigned_method @assigned_method end |
#assigned_singleton_original_class ⇒ Object
Returns the value of attribute assigned_singleton_original_class.
163 164 165 |
# File 'lib/neuroncheck/declaration.rb', line 163 def assigned_singleton_original_class @assigned_singleton_original_class end |
#attr_matcher ⇒ Object
Returns the value of attribute attr_matcher.
154 155 156 |
# File 'lib/neuroncheck/declaration.rb', line 154 def attr_matcher @attr_matcher end |
#declared_caller_locations ⇒ Object
Returns the value of attribute declared_caller_locations.
166 167 168 |
# File 'lib/neuroncheck/declaration.rb', line 166 def declared_caller_locations @declared_caller_locations end |
#postcond ⇒ Object
Returns the value of attribute postcond.
158 159 160 |
# File 'lib/neuroncheck/declaration.rb', line 158 def postcond @postcond end |
#postcond_allow_instance_method ⇒ Object
Returns the value of attribute postcond_allow_instance_method.
159 160 161 |
# File 'lib/neuroncheck/declaration.rb', line 159 def postcond_allow_instance_method @postcond_allow_instance_method end |
#precond ⇒ Object
Returns the value of attribute precond.
156 157 158 |
# File 'lib/neuroncheck/declaration.rb', line 156 def precond @precond end |
#precond_allow_instance_method ⇒ Object
Returns the value of attribute precond_allow_instance_method.
157 158 159 |
# File 'lib/neuroncheck/declaration.rb', line 157 def precond_allow_instance_method @precond_allow_instance_method end |
#return_matcher ⇒ Object
Returns the value of attribute return_matcher.
153 154 155 |
# File 'lib/neuroncheck/declaration.rb', line 153 def return_matcher @return_matcher end |
#shorthand ⇒ Object
Returns the value of attribute shorthand.
165 166 167 |
# File 'lib/neuroncheck/declaration.rb', line 165 def shorthand @shorthand end |
Instance Method Details
#assinged_to_singleton_method? ⇒ Boolean
194 195 196 |
# File 'lib/neuroncheck/declaration.rb', line 194 def assinged_to_singleton_method? @assigned_singleton_original_class end |
#assinged_to_toplevel_method? ⇒ Boolean
191 192 193 |
# File 'lib/neuroncheck/declaration.rb', line 191 def assinged_to_toplevel_method? @assigned_class_or_module == Object end |
#attribute? ⇒ Boolean
187 188 189 |
# File 'lib/neuroncheck/declaration.rb', line 187 def attribute? (@assigned_attribute_name ? true : false) end |
#meta_info_as_json ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/neuroncheck/declaration.rb', line 276 def re = {} if attribute? then re['value'] = (@attr_matcher ? @attr_matcher. : nil) re['signature_caption'] = signature_caption re['signature_caption_name_only'] = signature_caption_name_only else re['args'] = @arg_matchers.map{|x| x.} re['returns'] = (@return_matcher ? @return_matcher. : nil) re['signature_caption'] = signature_caption re['signature_caption_name_only'] = signature_caption_name_only end re['precond_source_location'] = (@precond ? @precond.source_location : nil) re['postcond_source_location'] = (@postcond ? @postcond.source_location : nil) re end |
#signature_caption ⇒ Object
メソッド名/属性名+引数+戻り値の表記文字列を取得
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/neuroncheck/declaration.rb', line 237 def signature_caption ret = signature_caption_name_only if ret then if attribute? then if @attr_matcher then ret << " -> #{@attr_matcher.expected_short_caption}" end else # 引数出力 unless @assigned_method.parameters.empty? then ret << "(" @assigned_method.parameters.each_with_index do |param_info, i| _, param_name = param_info if i >= 1 then ret << ", " end if (matcher = @arg_matchers[i]) then ret << "#{param_name}:#{matcher.expected_short_caption}" else ret << "#{param_name}:any" end end ret << ")" end if @return_matcher then ret << " -> #{@return_matcher.expected_short_caption}" end end return ret else nil end end |
#signature_caption_name_only ⇒ Object
メソッド名/属性名の表記文字列を取得
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/neuroncheck/declaration.rb', line 199 def signature_caption_name_only if @assigned_class_or_module and (@assigned_method or attribute?) then ret = "" # 属性、特異メソッド、インスタンスメソッドのそれぞれで処理を分岐 if attribute? then if @assigned_class_or_module.name then ret << @assigned_class_or_module.name end # 属性名出力 ret << "##{@assigned_attribute_name}" elsif assinged_to_toplevel_method? then # メソッド名出力 ret << "#{@assigned_method.name}" elsif assinged_to_singleton_method? then if @assigned_singleton_original_class.name then ret << @assigned_singleton_original_class.name end # メソッド名出力 ret << ".#{@assigned_method.name}" else if @assigned_class_or_module.name then ret << @assigned_class_or_module.name end # メソッド名出力 ret << "##{@assigned_method.name}" end else nil end end |