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.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#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, section, statement_number, context) ⇒ Statement
constructor
rubocop: disable Metrics/ParameterLists.
- #literal_regexp? ⇒ Boolean
- #match?(statement) ⇒ Boolean
- #pattern? ⇒ Boolean
- #scan(regex) ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
-
#type ⇒ Object
rubocop: enable Metrics/ParameterLists.
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def code @code end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def regexp @regexp end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
3 4 5 |
# File 'lib/korekto/statement.rb', line 3 def section @section 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
25 |
# File 'lib/korekto/statement.rb', line 25 def literal_regexp? = @statement[0]=='/' && @statement[-1]=='/' |
#match?(statement) ⇒ Boolean
22 |
# File 'lib/korekto/statement.rb', line 22 def match?(statement) = @regexp.match?(statement) |
#pattern? ⇒ 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_s ⇒ Object
20 |
# File 'lib/korekto/statement.rb', line 20 def to_s = @statement |
#to_str ⇒ Object
21 |
# File 'lib/korekto/statement.rb', line 21 def to_str = @statement |
#type ⇒ Object
rubocop: enable Metrics/ParameterLists
19 |
# File 'lib/korekto/statement.rb', line 19 def type = @code[0] |