Class: Dslable::Args

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArgs

Returns a new instance of Args.



11
12
13
14
# File 'lib/dslable_args.rb', line 11

def initialize
  @_desc = ''
  @_required = false
end

Instance Attribute Details

#_args_nameObject

Returns the value of attribute _args_name.



6
7
8
# File 'lib/dslable_args.rb', line 6

def _args_name
  @_args_name
end

#_default_valueObject

Returns the value of attribute _default_value.



9
10
11
# File 'lib/dslable_args.rb', line 9

def _default_value
  @_default_value
end

#_descObject

Returns the value of attribute _desc.



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

def _desc
  @_desc
end

#_klassObject

Returns the value of attribute _klass.



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

def _klass
  @_klass
end

#_requiredObject

Returns the value of attribute _required.



8
9
10
# File 'lib/dslable_args.rb', line 8

def _required
  @_required
end

Instance Method Details

#args_name(_args_name) ⇒ Object



21
22
23
24
25
26
# File 'lib/dslable_args.rb', line 21

def args_name(_args_name)
  fail InvalidArgsError.new('args_name not allow nil') if _args_name.nil?
  fail InvalidArgsError.new('args_name not allow empty') if _args_name.empty?
  fail InvalidArgsError.new('args_name allow /^[a-z0-9_]+$/') unless _args_name =~ /^[a-z0-9_]+$/
  @_args_name = _args_name
end

#default_value(_default_value) ⇒ Object



38
39
40
# File 'lib/dslable_args.rb', line 38

def default_value(_default_value)
  @_default_value = _default_value
end

#desc(_desc) ⇒ Object



16
17
18
19
# File 'lib/dslable_args.rb', line 16

def desc(_desc)
  return if _desc.nil?
  @_desc = _desc
end

#klass(_klass) ⇒ Object



28
29
30
31
32
# File 'lib/dslable_args.rb', line 28

def klass(_klass)
  fail InvalidArgsError.new('klass not allow nil') if _klass.nil?
  fail InvalidArgsError.new('klass only allow String, Array, Hash and :Boolean(true or false)') unless [String, Hash, Array, :Boolean].include? (_klass)
  @_klass = _klass
end

#requiredObject



34
35
36
# File 'lib/dslable_args.rb', line 34

def required
  @_required = true
end