Sha256: 99d963526e0803eb9d349f5a662f9332d849d19bba352afca1992725ead8e5fe

Contents?: true

Size: 1.21 KB

Versions: 6796

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

class Pry
  class Command
    class Ls < Pry::ClassCommand
      class InstanceVars < Pry::Command::Ls::Formatter
        include Pry::Command::Ls::Interrogatable

        def initialize(interrogatee, no_user_opts, opts, pry_instance)
          super(pry_instance)
          @interrogatee = interrogatee
          @no_user_opts = no_user_opts
          @default_switch = opts[:ivars]
        end

        def correct_opts?
          super || @no_user_opts
        end

        def output_self
          ivars = if Object === @interrogatee # rubocop:disable Style/CaseEquality
                    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

        private

        def format(type, vars)
          vars.sort_by { |var| var.to_s.downcase }.map { |var| color(type, var) }
        end
      end
    end
  end
end

Version data entries

6,796 entries across 6,792 versions & 31 rubygems

Version Path
cybrid_api_organization_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_bank_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_id_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_organization_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_bank_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_organization_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_id_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_bank_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_id_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_organization_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_bank_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_organization_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_id_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_organization_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_bank_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_id_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_organization_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/ls/instance_vars.rb