Class: Korekto::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/korekto/statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/korekto/statement.rb', line 3

def code
  @code
end

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/korekto/statement.rb', line 3

def filename
  @filename
end

#regexpObject (readonly)

Returns the value of attribute regexp.



3
4
5
# File 'lib/korekto/statement.rb', line 3

def regexp
  @regexp
end

#statement_numberObject (readonly)

Returns the value of attribute statement_number.



3
4
5
# File 'lib/korekto/statement.rb', line 3

def statement_number
  @statement_number
end

#titleObject (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

Returns:

  • (Boolean)


20
# File 'lib/korekto/statement.rb', line 20

def literal_regexp?   = @statement[0]=='/' && @statement[-1]=='/'

#match?(statement) ⇒ Boolean

Returns:

  • (Boolean)


17
# File 'lib/korekto/statement.rb', line 17

def match?(statement) = @regexp.match?(statement)

#pattern?Boolean

Returns:

  • (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_sObject



15
# File 'lib/korekto/statement.rb', line 15

def to_s              = @statement

#to_strObject



16
# File 'lib/korekto/statement.rb', line 16

def to_str            = @statement

#typeObject



14
# File 'lib/korekto/statement.rb', line 14

def type              = @code[0]