Class: Optitron

Inherits:
Object
  • Object
show all
Defined in:
lib/optitron.rb,
lib/optitron/cli.rb,
lib/optitron/dsl.rb,
lib/optitron/help.rb,
lib/optitron/option.rb,
lib/optitron/parser.rb,
lib/optitron/version.rb,
lib/optitron/response.rb,
lib/optitron/class_dsl.rb,
lib/optitron/tokenizer.rb

Defined Under Namespace

Modules: ClassDsl Classes: CLI, Dsl, Help, Option, Parser, Response, Tokenizer

Constant Summary collapse

InvalidParser =
Class.new(RuntimeError)
VERSION =
"0.3.3"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Optitron

Returns a new instance of Optitron.



15
16
17
18
# File 'lib/optitron.rb', line 15

def initialize(&blk)
  @parser = Parser.new
  Dsl.new(@parser, &blk) if blk
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



13
14
15
# File 'lib/optitron.rb', line 13

def parser
  @parser
end

Class Method Details

.transform(args = ARGV, &blk) ⇒ Object



24
25
26
# File 'lib/optitron.rb', line 24

def self.transform(args = ARGV, &blk)
  Optitron.new(&blk).parse(args)
end

Instance Method Details

#helpObject



28
29
30
# File 'lib/optitron.rb', line 28

def help
  @parser.help
end

#parse(args) ⇒ Object



20
21
22
# File 'lib/optitron.rb', line 20

def parse(args)
  @parser.parse(args)
end