Class: L43::OptParser::Keyword

Inherits:
Object
  • Object
show all
Extended by:
L43::OpenObject
Defined in:
lib/l43/opt_parser/keyword.rb

Constant Summary collapse

Result =
Core::Result

Instance Method Summary collapse

Instance Method Details

#assign_value(value) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/l43/opt_parser/keyword.rb', line 33

def assign_value(value)
  if arg_count > 0 && !multiple
    return Resut.error("must not assign multiple values to keyword #{name}")
  end

  assign_from_set(value).if_error { return it }

  value = init.(value) if init
  Result.ok(
    update_attribute(:arg_count, &:succ)
    .update_attribute(:value, simple_or_multiple(value))
  )
end

#real_nameObject



47
# File 'lib/l43/opt_parser/keyword.rb', line 47

def real_name = as || name