Class: Byebug::Setting
Overview
Parent class for all byebug settings.
Direct Known Subclasses
AutoevalSetting, AutoirbSetting, AutolistSetting, AutosaveSetting, BasenameSetting, CallstyleSetting, FullpathSetting, HistfileSetting, HistsizeSetting, LinetraceSetting, ListsizeSetting, PostMortemSetting, StackOnErrorSetting, VerboseSetting, WidthSetting
Constant Summary
collapse
- DEFAULT =
false
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
camelize, prettify
Constructor Details
Returns a new instance of Setting.
12
13
14
|
# File 'lib/byebug/setting.rb', line 12
def initialize
@value = self.class::DEFAULT
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
8
9
10
|
# File 'lib/byebug/setting.rb', line 8
def value
@value
end
|
Class Method Details
.[](name) ⇒ Object
46
47
48
|
# File 'lib/byebug/setting.rb', line 46
def [](name)
settings[name].value
end
|
.[]=(name, value) ⇒ Object
50
51
52
|
# File 'lib/byebug/setting.rb', line 50
def []=(name, value)
settings[name].value = value
end
|
.find(shortcut) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/byebug/setting.rb', line 54
def find(shortcut)
abbr = shortcut =~ /^no/ ? shortcut[2..-1] : shortcut
matches = settings.select do |key, value|
value.boolean? ? key =~ /#{abbr}/ : key =~ /#{shortcut}/
end
matches.size == 1 ? matches.values.first : nil
end
|
.help(cmd, subcmd) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/byebug/setting.rb', line 71
def help(cmd, subcmd)
unless subcmd
command = Byebug.const_get("#{cmd.capitalize}Command")
return command.description + help_all
end
setting = find(subcmd)
prettify <<-EOS
#{cmd} #{setting.to_sym} <value>
#{setting.banner}.
EOS
end
|
.help_all ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/byebug/setting.rb', line 62
def help_all
output = " List of settings supported in byebug:\n --\n"
width = settings.keys.max_by(&:size).size
settings.values.each do |sett|
output << format(" %-#{width}s -- %s\n", sett.to_sym, sett.banner)
end
output + "\n"
end
|
.settings ⇒ Object
42
43
44
|
# File 'lib/byebug/setting.rb', line 42
def settings
@settings ||= {}
end
|
Instance Method Details
#boolean? ⇒ Boolean
16
17
18
|
# File 'lib/byebug/setting.rb', line 16
def boolean?
[true, false].include?(value)
end
|
#help ⇒ Object
26
27
28
|
# File 'lib/byebug/setting.rb', line 26
def help
"\n #{banner}.\n\n"
end
|
#integer? ⇒ Boolean
20
21
22
23
24
|
# File 'lib/byebug/setting.rb', line 20
def integer?
Integer(value) ? true : false
rescue ArgumentError
false
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/byebug/setting.rb', line 35
def to_s
"#{to_sym} is #{value ? 'on' : 'off'}\n"
end
|
#to_sym ⇒ Object
30
31
32
33
|
# File 'lib/byebug/setting.rb', line 30
def to_sym
name = self.class.name.gsub(/^Byebug::/, '').gsub(/Setting$/, '')
name.gsub(/(.)([A-Z])/, '\1_\2').downcase.to_sym
end
|