Class: Relish::Command::Config::Option

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

Constant Summary collapse

VALID_OPTIONS =
%w(project)

Instance Method Summary collapse

Constructor Details

#initialize(param) ⇒ Option

Returns a new instance of Option.



8
9
10
11
# File 'lib/relish/commands/config.rb', line 8

def initialize(param)
  @option, @value = param.split(':')
  validate_option
end

Instance Method Details

#to_hashObject



20
21
22
# File 'lib/relish/commands/config.rb', line 20

def to_hash
  {@option => @value}
end

#validate_optionObject



13
14
15
16
17
18
# File 'lib/relish/commands/config.rb', line 13

def validate_option
  unless VALID_OPTIONS.include?(@option)
    Relish::Helpers.error "'#{@option}' is not a valid option." +
                          " Valid options: #{VALID_OPTIONS.join(', ')}"
  end
end