Class: Korekto::Statements
- Inherits:
-
Object
- Object
- Korekto::Statements
- Defined in:
- lib/korekto/statements.rb
Instance Attribute Summary collapse
-
#heap ⇒ Object
readonly
Returns the value of attribute heap.
-
#symbols ⇒ Object
readonly
Returns the value of attribute symbols.
-
#syntax ⇒ Object
readonly
Returns the value of attribute syntax.
Instance Method Summary collapse
- #add(statement, code, title, filename) ⇒ Object
-
#initialize ⇒ Statements
constructor
A new instance of Statements.
- #last ⇒ Object
- #length ⇒ Object
- #type(c) ⇒ Object
Constructor Details
Instance Attribute Details
#heap ⇒ Object (readonly)
Returns the value of attribute heap.
3 4 5 |
# File 'lib/korekto/statements.rb', line 3 def heap @heap end |
#symbols ⇒ Object (readonly)
Returns the value of attribute symbols.
3 4 5 |
# File 'lib/korekto/statements.rb', line 3 def symbols @symbols end |
#syntax ⇒ Object (readonly)
Returns the value of attribute syntax.
3 4 5 |
# File 'lib/korekto/statements.rb', line 3 def syntax @syntax end |
Instance Method Details
#add(statement, code, title, filename) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/korekto/statements.rb', line 16 def add(statement,code,title,filename) c = code[0]; w = c=='W' if (restatement=@statements.detect{(w || _1.type==c) && _1.to_s==statement}) unless 'DXSPTCR'.include?(restatement.type) # Only allow heap-able statements to be restated. raise Error, "restatement: #{restatement.code}" end @heap.add restatement code, = restatement.code title ||= restatement.title return code, title end statement_number = yield statement=Statement.new(statement,code,title,filename,statement_number,self) @statements.push statement @symbols.define! statement if 'AIEMLDXS'.include?(statement.type) @heap.add statement if 'DXSPTCR'.include?(statement.type) [statement.code, statement.title] end |
#last ⇒ Object
14 |
# File 'lib/korekto/statements.rb', line 14 def last = @statements.last |
#length ⇒ Object
13 |
# File 'lib/korekto/statements.rb', line 13 def length = @statements.length |
#type(c) ⇒ Object
12 |
# File 'lib/korekto/statements.rb', line 12 def type(c) = @statements.select{_1.type==c} |