Class: TCOMethod::MethodInfo
- Inherits:
-
Object
- Object
- TCOMethod::MethodInfo
- Defined in:
- lib/tco_method/method_info.rb
Overview
Class encapsulating the behaviors required to extract information about a method from the 14-element Array of data representing the instruction sequence of that method.
Constant Summary collapse
- VALID_METHOD_CLASSES =
A collection of those classes that will be recognized as methods and can be used effectively with this class.
[ Method, UnboundMethod, ].freeze
Instance Method Summary collapse
-
#initialize(method_obj) ⇒ MethodInfo
constructor
Creates a new MethodInfo instance.
-
#type ⇒ Symbol
Returns the type of the method object as reported by the Array of data describing the instruction sequence representing the method.
Constructor Details
#initialize(method_obj) ⇒ MethodInfo
Creates a new MethodInfo instance.
20 21 22 23 24 25 26 |
# File 'lib/tco_method/method_info.rb', line 20 def initialize(method_obj) unless VALID_METHOD_CLASSES.any? { |klass| method_obj.is_a?(klass) } msg = "Invalid argument! Method or UnboundMethod expected, received #{method_obj.class.name}" raise TypeError, msg end @info = RubyVM::InstructionSequence.of(method_obj).to_a end |
Instance Method Details
#type ⇒ Symbol
Returns the type of the method object as reported by the Array of data describing the instruction sequence representing the method.
35 36 37 |
# File 'lib/tco_method/method_info.rb', line 35 def type @info[9] end |