Class: CLI::UI::Widgets::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/ui/widgets/base.rb

Direct Known Subclasses

Status

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argstring) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
19
# File 'lib/cli/ui/widgets/base.rb', line 11

def initialize(argstring)
  pat = self.class.argparse_pattern
  unless (@match_data = pat.match(argstring))
    raise(Widgets::InvalidWidgetArguments.new(argstring, pat))
  end
  @match_data.names.each do |name|
    instance_variable_set(:"@#{name}", @match_data[name])
  end
end

Class Method Details

.argparse_patternObject



21
22
23
# File 'lib/cli/ui/widgets/base.rb', line 21

def self.argparse_pattern
  const_get(:ARGPARSE_PATTERN)
end

.call(argstring) ⇒ Object



7
8
9
# File 'lib/cli/ui/widgets/base.rb', line 7

def self.call(argstring)
  new(argstring).render
end