Class: Pry::Command::Ls::InstanceVars
- Includes:
- Interrogatable
- Defined in:
- lib/pry/commands/ls/instance_vars.rb
Instance Attribute Summary
Attributes inherited from Formatter
Instance Method Summary collapse
- #correct_opts? ⇒ Boolean
-
#initialize(interrogatee, no_user_opts, opts, _pry_) ⇒ InstanceVars
constructor
A new instance of InstanceVars.
- #output_self ⇒ Object
Methods inherited from Formatter
Constructor Details
#initialize(interrogatee, no_user_opts, opts, _pry_) ⇒ InstanceVars
Returns a new instance of InstanceVars.
8 9 10 11 12 13 |
# File 'lib/pry/commands/ls/instance_vars.rb', line 8 def initialize(interrogatee, no_user_opts, opts, _pry_) super(_pry_) @interrogatee = interrogatee @no_user_opts = no_user_opts @default_switch = opts[:ivars] end |
Instance Method Details
#correct_opts? ⇒ Boolean
15 16 17 |
# File 'lib/pry/commands/ls/instance_vars.rb', line 15 def correct_opts? super || @no_user_opts end |
#output_self ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pry/commands/ls/instance_vars.rb', line 19 def output_self ivars = if Object === @interrogatee Pry::Method.safe_send(@interrogatee, :instance_variables) else [] #TODO: BasicObject support end kvars = Pry::Method.safe_send(interrogatee_mod, :class_variables) ivars_out = output_section('instance variables', format(:instance_var, ivars)) kvars_out = output_section('class variables', format(:class_var, kvars)) ivars_out + kvars_out end |