Class: Dslable::Dsl

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDsl

Returns a new instance of Dsl.



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

def initialize
  @fields = []
end

Instance Attribute Details

#_bin_nameObject

Returns the value of attribute _bin_name.



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

def _bin_name
  @_bin_name
end

#_gem_descObject

Returns the value of attribute _gem_desc.



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

def _gem_desc
  @_gem_desc
end

#_gem_nameObject

Returns the value of attribute _gem_name.



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

def _gem_name
  @_gem_name
end

#fieldsObject

Returns the value of attribute fields.



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

def fields
  @fields
end

Instance Method Details

#bin_name(_bin_name) ⇒ Object

Raises:



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

def bin_name(_bin_name)
  raise InvalidDslError.new("bin_name not allow nil") if _bin_name.nil?
  raise InvalidDslError.new("bin_name not allow empty") if _bin_name.empty?
  raise InvalidDslError.new("bin_name allow /^[a-z0-9_]+$/") unless _bin_name =~ /^[a-z0-9_]+$/
  @_bin_name = _bin_name
end

#camelized_gem_nameObject



44
45
46
# File 'lib/dslable_dsl.rb', line 44

def camelized_gem_name
  _gem_name.camelize
end

#field(_field_name) {|_field| ... } ⇒ Object

Yields:

  • (_field)

Raises:



35
36
37
38
39
40
41
42
# File 'lib/dslable_dsl.rb', line 35

def field(_field_name)
  raise InvalidDslError.new("field name not allow nil") if _field_name.nil?
  raise InvalidDslError.new("field name not allow empty") if _field_name.empty?
  _field = Field.new
  _field.field_name _field_name
  yield _field
  @fields << _field
end

#gem_desc(_gem_desc) ⇒ Object

Raises:



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

def gem_desc(_gem_desc)
  raise InvalidDslError.new("gem_desc not allow nil") if _gem_desc.nil?
  raise InvalidDslError.new("gem_desc not allow empty") if _gem_desc.empty?
  @_gem_desc = _gem_desc
end

#gem_name(_gem_name) ⇒ Object

Raises:



15
16
17
18
19
20
# File 'lib/dslable_dsl.rb', line 15

def gem_name(_gem_name)
  raise InvalidDslError.new("gem_name not allow nil") if _gem_name.nil?
  raise InvalidDslError.new("gem_name not allow empty") if _gem_name.empty?
  raise InvalidDslError.new("gem_name allow /^[a-z0-9_]+$/") unless _gem_name =~ /^[a-z0-9_]+$/
  @_gem_name = _gem_name
end