Class: Bunto::Compose::ArgParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bunto-compose/arg_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options) ⇒ ArgParser

Returns a new instance of ArgParser.



3
4
5
6
# File 'lib/bunto-compose/arg_parser.rb', line 3

def initialize(args, options)
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



2
3
4
# File 'lib/bunto-compose/arg_parser.rb', line 2

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



2
3
4
# File 'lib/bunto-compose/arg_parser.rb', line 2

def options
  @options
end

Instance Method Details

#force?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bunto-compose/arg_parser.rb', line 24

def force?
  !!options["force"]
end

#layoutObject



16
17
18
# File 'lib/bunto-compose/arg_parser.rb', line 16

def layout
  layout = options["layout"] || Bunto::Compose::DEFAULT_LAYOUT
end

#titleObject



20
21
22
# File 'lib/bunto-compose/arg_parser.rb', line 20

def title
  args.join ' '
end

#typeObject



12
13
14
# File 'lib/bunto-compose/arg_parser.rb', line 12

def type
  type = options["extension"] || Bunto::Compose::DEFAULT_TYPE
end

#validate!Object

Raises:

  • (ArgumentError)


8
9
10
# File 'lib/bunto-compose/arg_parser.rb', line 8

def validate!
  raise ArgumentError.new('You must specify a name.') if args.empty?
end