Class: Envandle::Element
- Inherits:
-
Object
show all
- Defined in:
- lib/envandle/element.rb
Instance Method Summary
collapse
Constructor Details
#initialize(loc, context, *args, &block) ⇒ Element
Returns a new instance of Element.
3
4
5
6
7
|
# File 'lib/envandle/element.rb', line 3
def initialize(loc, context, *args, &block)
@loc = loc
@context = context
@args = Argset.new(self, *args, &block)
end
|
Instance Method Details
#<<(child) ⇒ Object
50
51
52
53
|
# File 'lib/envandle/element.rb', line 50
def <<(child)
children << child
children_by_type(child.type) << child
end
|
#children ⇒ Object
38
39
40
|
# File 'lib/envandle/element.rb', line 38
def children
@children ||= []
end
|
#children_by_type(type = nil) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/envandle/element.rb', line 42
def children_by_type(type = nil)
if type
(@children_by_type ||= {})[type] ||= []
else
@children_by_type ||= {}
end
end
|
#draw(&block) ⇒ Object
33
34
35
36
|
# File 'lib/envandle/element.rb', line 33
def draw(&block)
block ||= @args.block
dsl.instance_exec &block if block
end
|
#dsl ⇒ Object
29
30
31
|
# File 'lib/envandle/element.rb', line 29
def dsl
self.class::Dsl.new(self)
end
|
#gemfile ⇒ Object
21
22
23
|
# File 'lib/envandle/element.rb', line 21
def gemfile
@context.gemfile
end
|
#groups_or_default ⇒ Object
25
26
27
|
# File 'lib/envandle/element.rb', line 25
def groups_or_default
@context.groups_or_default
end
|
#history_argsets ⇒ Object
67
68
69
|
# File 'lib/envandle/element.rb', line 67
def history_argsets
bundler_argsets
end
|
#parse_string_option(name, type) ⇒ Object
17
18
19
|
# File 'lib/envandle/element.rb', line 17
def parse_string_option(name, type)
parse_string_value(@args.options[name], type)
end
|
#parse_string_value(v, type) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/envandle/element.rb', line 9
def parse_string_value(v, type)
if v
v = v.to_s.strip
Envandle.arg! @loc, type if v.empty?
v
end
end
|
#send_to_bundler(receiver) ⇒ Object
55
56
57
58
59
|
# File 'lib/envandle/element.rb', line 55
def send_to_bundler(receiver)
bundler_argsets.each do |i|
i.send_to receiver
end
end
|
#send_to_history(receiver) ⇒ Object
61
62
63
64
65
|
# File 'lib/envandle/element.rb', line 61
def send_to_history(receiver)
history_argsets.each do |i|
i.send_to receiver
end
end
|