Class: Pry::Command::Ls::Constants

Inherits:
Formatter show all
Includes:
Interrogatable
Defined in:
lib/pry/commands/ls/constants.rb

Instance Attribute Summary

Attributes inherited from Formatter

#_pry_

Instance Method Summary collapse

Methods inherited from Formatter

#write_out

Constructor Details

#initialize(interrogatee, no_user_opts, opts, _pry_) ⇒ Constants

Returns a new instance of Constants.



9
10
11
12
13
14
15
# File 'lib/pry/commands/ls/constants.rb', line 9

def initialize(interrogatee, no_user_opts, opts, _pry_)
  super(_pry_)
  @interrogatee = interrogatee
  @no_user_opts = no_user_opts
  @default_switch = opts[:constants]
  @verbose_switch = opts[:verbose]
end

Instance Method Details

#correct_opts?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pry/commands/ls/constants.rb', line 17

def correct_opts?
  super || (@no_user_opts && interrogating_a_module?)
end

#output_selfObject



21
22
23
24
25
# File 'lib/pry/commands/ls/constants.rb', line 21

def output_self
  mod = interrogatee_mod
  constants = WrappedModule.new(mod).constants(@verbose_switch)
  output_section('constants', grep.regexp[format(mod, constants)])
end