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, statement_number) ⇒ Object
-
#initialize ⇒ Statements
constructor
A new instance of Statements.
- #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, statement_number) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/korekto/statements.rb', line 14 def add(statement,code,title,filename,statement_number) c = code[0]; w = c=='W' if restatement = @statements.detect{(w or _1.type==c) and _1.to_s==statement} case restatement.type when 'D','X','S','P','T','C','R' @heap.add restatement else raise Error, "restatement: #{restatement.code}" end code,_ = restatement.code title ||= restatement.title return code, title end statement = Statement.new(statement,code,title,filename,statement_number,self) @statements.push statement case statement.type when 'A','I','E','M','L' @symbols.define! statement when 'D','X','S' @symbols.define! statement @heap.add statement when 'P','T','C','R' @heap.add statement end return statement.code, statement.title end |
#length ⇒ Object
12 |
# File 'lib/korekto/statements.rb', line 12 def length = @statements.length |
#type(c) ⇒ Object
11 |
# File 'lib/korekto/statements.rb', line 11 def type(c) = @statements.select{_1.type==c} |