Class: Dramaturg::Command
- Inherits:
-
Object
- Object
- Dramaturg::Command
show all
- Includes:
- AsCollection, Opt
- Defined in:
- lib/dramaturg/command.rb,
lib/dramaturg/command/as_collection.rb
Defined Under Namespace
Modules: AsCollection, Opt
Instance Attribute Summary collapse
-
#ok ⇒ Object
(also: #ok?, #success?, #succeeded?)
Returns the value of attribute ok.
-
#ran ⇒ Object
Returns the value of attribute ran.
Instance Method Summary
collapse
#<<, #[], #[]=, #each, #output
Constructor Details
#initialize(cmd_str, script) ⇒ Command
22
23
24
25
26
27
|
# File 'lib/dramaturg/command.rb', line 22
def initialize(cmd_str, script)
@input_string = cmd_str
@script = script
@values = []
@outputs = {}
end
|
Instance Attribute Details
#ok ⇒ Object
Also known as:
ok?, success?, succeeded?
Returns the value of attribute ok.
46
47
48
|
# File 'lib/dramaturg/command.rb', line 46
def ok
@ok
end
|
#ran ⇒ Object
Returns the value of attribute ran.
33
34
35
|
# File 'lib/dramaturg/command.rb', line 33
def ran
@ran
end
|
Instance Method Details
#ran? ⇒ Boolean
34
35
36
37
|
# File 'lib/dramaturg/command.rb', line 34
def ran?
@ran ||= false
@ran || @skipped
end
|
#run ⇒ Object
29
30
31
32
|
# File 'lib/dramaturg/command.rb', line 29
def run
@script.execute(self)
self
end
|
#skip ⇒ Object
39
40
41
42
43
|
# File 'lib/dramaturg/command.rb', line 39
def skip
@ok = :skipped
@skipped = true
@outputs.each {|k,_| @outputs[k] = Value::Unknown.new() }
end
|
#skipped? ⇒ Boolean
44
|
# File 'lib/dramaturg/command.rb', line 44
def skipped?; @skipped ||= false; end
|
#to_s ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/dramaturg/command.rb', line 51
def to_s
if @values.empty?
@input_string
else
self.map {|t| t.to_s}.join ''
end
end
|