Sha256: 550486dc3f604ea452b5560378a891e9102016d27cd6ba22de60c19555fa866b

Contents?: true

Size: 1.11 KB

Versions: 159

Compression:

Stored size: 1.11 KB

Contents

require 'pry/commands/ls/interrogatable'

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

      def initialize(interrogatee, no_user_opts, opts, _pry_)
        super(_pry_)
        @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
                  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

Version data entries

159 entries across 152 versions & 35 rubygems

Version Path
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/pry-0.10.4-java/lib/pry/commands/ls/instance_vars.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
tdiary-5.0.5 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/pry-0.10.4-java/lib/pry/commands/ls/instance_vars.rb
logstash-filter-htmlentities-0.1.0 vendor/bundle/jruby/1.9/gems/pry-0.10.4-java/lib/pry/commands/ls/instance_vars.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/pry-0.10.4-java/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.2.1 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.2.0 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.9 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.8 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.7 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.6 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.4 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
tdiary-5.0.4 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/pry-0.10.4-java/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.3 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.2 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.1 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb
lazy_record-0.1.0 vendor/bundle/gems/pry-0.10.4/lib/pry/commands/ls/instance_vars.rb