Class: Yarsh::Config
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #add_alias(name, command) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #prompt ⇒ Object
- #prompt=(prompt) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 |
# File 'lib/yarsh/config.rb', line 18 def initialize @aliases = {} @prompt = nil @logger = Logger.new($stdout, level: Logger::UNKNOWN) end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
15 16 17 |
# File 'lib/yarsh/config.rb', line 15 def aliases @aliases end |
#log_level ⇒ Object
Returns the value of attribute log_level.
15 16 17 |
# File 'lib/yarsh/config.rb', line 15 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
16 17 18 |
# File 'lib/yarsh/config.rb', line 16 def logger @logger end |
Instance Method Details
#add_alias(name, command) ⇒ Object
29 30 31 32 |
# File 'lib/yarsh/config.rb', line 29 def add_alias(name, command) = Yarsh.(command, @aliases) @aliases[name.to_s] = end |
#prompt ⇒ Object
34 35 36 37 38 39 |
# File 'lib/yarsh/config.rb', line 34 def prompt prompt_method = @prompt || :basic return Prompt.method(prompt_method).call if prompt_method.is_a? Symbol @prompt.call end |
#prompt=(prompt) ⇒ Object
41 42 43 44 45 |
# File 'lib/yarsh/config.rb', line 41 def prompt=(prompt) raise InvalidPromptError unless prompt.respond_to?(:call) || Prompt.respond_to?(prompt) @prompt = prompt end |