# class Byebug::Setting

Parent class for all byebug settings.

### Constants

DEFAULT

### Attributes

value[RW]

### Public Class Methods

[](name) click to toggle source

    # File lib/byebug/setting.rb, line 46
    def [](name)
      settings[name].value
    end

[]=(name, value) click to toggle source

    # File lib/byebug/setting.rb, line 50
    def []=(name, value)
      settings[name].value = value
    end

find(shortcut) click to toggle source

    # 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) click to toggle source

    # 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() click to toggle source

    # 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

new() click to toggle source

    # File lib/byebug/setting.rb, line 12
    def initialize
      @value = self.class::DEFAULT
    end

settings() click to toggle source

    # File lib/byebug/setting.rb, line 42
    def settings
      @settings ||= {}
    end

### Public Instance Methods

boolean?() click to toggle source

    # File lib/byebug/setting.rb, line 16
    def boolean?
      [true, false].include?(value)
    end

help() click to toggle source

    # File lib/byebug/setting.rb, line 26
    def help
      "\n  #{banner}.\n\n"
    end

integer?() click to toggle source

    # File lib/byebug/setting.rb, line 20
    def integer?
      Integer(value) ? true : false
    rescue ArgumentError
      false
    end

to_s() click to toggle source

    # File lib/byebug/setting.rb, line 35
    def to_s
      "#{to_sym} is #{value ? 'on' : 'off'}\n"
    end

to_sym() click to toggle source

    # 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