Class: Eastrails::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/eastrails/parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = []) ⇒ Parameters

Returns a new instance of Parameters.



7
8
9
10
11
# File 'lib/eastrails/parameters.rb', line 7

def initialize(args = [])
  self.args = args.dup
  self.non_options = args.select { |arg| !arg.start_with?("-") }
  parse_options
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/eastrails/parameters.rb', line 3

def args
  @args
end

#non_optionsObject

Returns the value of attribute non_options.



5
6
7
# File 'lib/eastrails/parameters.rb', line 5

def non_options
  @non_options
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/eastrails/parameters.rb', line 4

def options
  @options
end

Instance Method Details

#commandObject



29
30
31
# File 'lib/eastrails/parameters.rb', line 29

def command
  non_options[0] || "help"
end

#componentObject



33
34
35
# File 'lib/eastrails/parameters.rb', line 33

def component
  non_options[1]
end

#parse_optionsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/eastrails/parameters.rb', line 13

def parse_options
  self.options = {}
  parser = OptionParser.new do |opts|
    opts.on('-v', '--verbose', 'Print debugging details') do
      options[:verbose] = true
    end

    opts.on('-b', '--bundle', 'Run bundle after complete') do
      options[:bundle] = true
    end

    opts.on('-d', '--database', "Specify the database adapter as of eastrails new")
  end
  parser.parse!(args)
end