Class: Stupidedi::Builder::IdentifierStack::ST
- Defined in:
- lib/stupidedi/builder/identifier_stack.rb
Instance Attribute Summary collapse
-
#sequence ⇒ Object
writeonly
Sets the attribute sequence.
Instance Method Summary collapse
-
#count(builder) ⇒ Object
Number of segments (ST..SE).
- #hl ⇒ Object
- #id ⇒ Object
-
#initialize(parent, id) ⇒ ST
constructor
A new instance of ST.
- #pop ⇒ Object
Constructor Details
#initialize(parent, id) ⇒ ST
Returns a new instance of ST.
106 107 108 |
# File 'lib/stupidedi/builder/identifier_stack.rb', line 106 def initialize(parent, id) @sequence, @parent, @id = 0, parent, id end |
Instance Attribute Details
#sequence=(value) ⇒ Object (writeonly)
Sets the attribute sequence
104 105 106 |
# File 'lib/stupidedi/builder/identifier_stack.rb', line 104 def sequence=(value) @sequence = value end |
Instance Method Details
#count(builder) ⇒ Object
Number of segments (ST..SE)
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/stupidedi/builder/identifier_stack.rb', line 119 def count(builder) m = Either.success(builder.machine) while m.defined? if m.flatmap(&:segment).map{|s| s.node.id == :ST }.fetch(false) return m.flatmap{|n| n.distance(builder.machine) }.fetch(0) + 2 else m = m.flatmap(&:parent) end end end |
#hl ⇒ Object
110 111 112 |
# File 'lib/stupidedi/builder/identifier_stack.rb', line 110 def hl HL.new(self, @sequence += 1) end |
#id ⇒ Object
114 115 116 |
# File 'lib/stupidedi/builder/identifier_stack.rb', line 114 def id @id.to_s.rjust(4, "0") end |
#pop ⇒ Object
131 132 133 |
# File 'lib/stupidedi/builder/identifier_stack.rb', line 131 def pop @parent end |