Class: Korekto::Statement
- Inherits:
-
Object
- Object
- Korekto::Statement
- Defined in:
- lib/korekto/statement.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
-
#statement_number ⇒ Object
readonly
Returns the value of attribute statement_number.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(statement, code, title, filename, statement_number, context) ⇒ Statement
constructor
A new instance of Statement.
- #literal_regexp? ⇒ Boolean
- #match?(statement) ⇒ Boolean
- #pattern? ⇒ Boolean
- #scan(regex, &blk) ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(statement, code, title, filename, statement_number, context) ⇒ Statement
Returns a new instance of Statement.
4 5 6 7 8 9 10 11 12 |
# File 'lib/korekto/statement.rb', line 4 def initialize(statement,code,title,filename,statement_number,context) @statement,@code,@title,@statement_number,@context = statement,code,title,statement_number,context @filename = File.basename(filename,'.*') @statement.freeze; @filename.freeze; @statement_number.freeze syntax_check unless @statement[0]=='/' and @statement[-1]=='/' and ['A','L','M','E','I'].include?(@code[0]) @regexp = nil set_acceptance_code @code.freeze; @title.freeze; @regexp.freeze end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def code @code end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def filename @filename end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def regexp @regexp end |
#statement_number ⇒ Object (readonly)
Returns the value of attribute statement_number.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def statement_number @statement_number end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def title @title end |
Instance Method Details
#literal_regexp? ⇒ Boolean
20 |
# File 'lib/korekto/statement.rb', line 20 def literal_regexp? = @statement[0]=='/' && @statement[-1]=='/' |
#match?(statement) ⇒ Boolean
17 |
# File 'lib/korekto/statement.rb', line 17 def match?(statement) = @regexp.match?(statement) |
#pattern? ⇒ Boolean
19 |
# File 'lib/korekto/statement.rb', line 19 def pattern? = !@regexp.nil? |
#scan(regex, &blk) ⇒ Object
18 |
# File 'lib/korekto/statement.rb', line 18 def scan(regex, &blk) = @statement.scan(regex, &blk) |
#to_s ⇒ Object
15 |
# File 'lib/korekto/statement.rb', line 15 def to_s = @statement |
#to_str ⇒ Object
16 |
# File 'lib/korekto/statement.rb', line 16 def to_str = @statement |
#type ⇒ Object
14 |
# File 'lib/korekto/statement.rb', line 14 def type = @code[0] |