Class: AocCli::Commands::DefaultAlias

Inherits:
Object
  • Object
show all
Defined in:
lib/aoc_cli/commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ DefaultAlias

Returns a new instance of DefaultAlias.



104
105
106
107
# File 'lib/aoc_cli/commands.rb', line 104

def initialize(args)
	@user = args[:user]
	@mode = user.nil? ? :get : :set
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



103
104
105
# File 'lib/aoc_cli/commands.rb', line 103

def mode
  @mode
end

#userObject (readonly)

Returns the value of attribute user.



103
104
105
# File 'lib/aoc_cli/commands.rb', line 103

def user
  @user
end

Instance Method Details

#execObject



108
109
110
111
# File 'lib/aoc_cli/commands.rb', line 108

def exec
	set if mode == :set && alias_valid
	self
end

#respondObject



112
113
114
115
116
# File 'lib/aoc_cli/commands.rb', line 112

def respond
	case mode
	when :get then current
	when :set then update end
end