Class: Lab42::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/lab42/options.rb,
lib/lab42/options/parser.rb,
lib/lab42/options/version.rb

Defined Under Namespace

Classes: Parser

Constant Summary collapse

VERSION =
"0.4.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#yaml_fileObject (readonly)

Returns the value of attribute yaml_file.



7
8
9
# File 'lib/lab42/options.rb', line 7

def yaml_file
  @yaml_file
end

Instance Method Details

#parse(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/lab42/options.rb', line 9

def parse *args
  args = args.first if Array === args.first
  @parsed = Lab42::Options::Parser.new.parse( self, args )
  set_defaults
  check_required
  issue_errors!
  result = OpenStruct.new @parsed
  result.forwarding_to :kwds
end

#read_from(file_sym_or_hash) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/lab42/options.rb', line 19

def read_from file_sym_or_hash
  case file_sym_or_hash
  when String
    read_from_file file_sym_or_hash
  when Symbol
    read_from_parameterized_file file_sym_or_hash => nil
  else
    read_from_parameterized_file file_sym_or_hash
  end
end