Class: Interscript::Node::Stage
- Inherits:
-
Group::Sequential
- Object
- Interscript::Node
- Group
- Group::Sequential
- Interscript::Node::Stage
- Defined in:
- lib/interscript/node/stage.rb
Instance Attribute Summary collapse
-
#doc_name ⇒ Object
Returns the value of attribute doc_name.
-
#dont_reverse ⇒ Object
Returns the value of attribute dont_reverse.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Group
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name = :main, reverse_run: nil, doc_name: nil, dont_reverse: false) ⇒ Stage
constructor
A new instance of Stage.
- #inspect ⇒ Object
- #reverse ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Group
#apply_order, #reorder_children, #to_visualization_array
Constructor Details
#initialize(name = :main, reverse_run: nil, doc_name: nil, dont_reverse: false) ⇒ Stage
Returns a new instance of Stage.
4 5 6 7 8 9 |
# File 'lib/interscript/node/stage.rb', line 4 def initialize(name = :main, reverse_run: nil, doc_name: nil, dont_reverse: false) @name = name @doc_name = doc_name @dont_reverse = dont_reverse super(reverse_run: reverse_run) end |
Instance Attribute Details
#doc_name ⇒ Object
Returns the value of attribute doc_name.
2 3 4 |
# File 'lib/interscript/node/stage.rb', line 2 def doc_name @doc_name end |
#dont_reverse ⇒ Object
Returns the value of attribute dont_reverse.
2 3 4 |
# File 'lib/interscript/node/stage.rb', line 2 def dont_reverse @dont_reverse end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/interscript/node/stage.rb', line 2 def name @name end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/interscript/node/stage.rb', line 30 def ==(other) super && self.name == other.name && self.reverse_run == other.reverse_run && self.dont_reverse == other.dont_reverse end |
#inspect ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/interscript/node/stage.rb', line 37 def inspect args = [] args << "#{@name}" if @name != :main args << "dont_reverse: true" if dont_reverse name = "" name = "(#{args.join(", ")})" unless args.empty? "stage#{name} {\n#{super}\n}" end |
#reverse ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/interscript/node/stage.rb', line 17 def reverse return self if dont_reverse @reverse ||= begin self.class.new(name, doc_name: Interscript::Node::Document.reverse_name(doc_name), reverse_run: reverse_run.nil? ? nil : !reverse_run ).tap do |r| r.children = self.children.reverse.map(&:reverse) end end end |
#to_hash ⇒ Object
11 12 13 14 15 |
# File 'lib/interscript/node/stage.rb', line 11 def to_hash { :class => self.class.to_s, :name => name, :children => @children.map{|x| x.to_hash} } end |