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, section, statement_number, context) ⇒ Statement

rubocop: disable Metrics/ParameterLists



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/korekto/statement.rb', line 6

def initialize(statement,code,title,section,statement_number,context)
  @statement,@code,@title,@section,@statement_number,@context,@regexp =
    statement,code,title,section,statement_number,context,nil
  @statement.freeze; @section.freeze; @statement_number.freeze
  @title = @title.split(':',2).first if @title
  syntax_check unless @statement[0]=='/' &&
                      @statement[-1]=='/' &&
                      %w[A L M E I].include?(@code[0])
  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

#regexpObject (readonly)

Returns the value of attribute regexp.



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

def regexp
  @regexp
end

#sectionObject (readonly)

Returns the value of attribute section.



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

def section
  @section
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)


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

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

#match?(statement) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#pattern?Boolean

Returns:

  • (Boolean)


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

def pattern?          = !@regexp.nil?

#scan(regex) ⇒ Object



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

def scan(regex, &)    = @statement.scan(regex, &)

#to_sObject



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

def to_s              = @statement

#to_strObject



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

def to_str            = @statement

#typeObject

rubocop: enable Metrics/ParameterLists



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

def type              = @code[0]