Class: OCL::Label
- Inherits:
-
Object
- Object
- OCL::Label
- Defined in:
- lib/dbc/ocl.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message, file, line) ⇒ Label
constructor
A new instance of Label.
- #to_s(context = nil) ⇒ Object
Constructor Details
#initialize(message, file, line) ⇒ Label
Returns a new instance of Label.
24 25 26 27 28 29 30 31 |
# File 'lib/dbc/ocl.rb', line 24 def initialize(, file, line) @message = if =~ /[\n\r"]/ raise ParseError, "label '#{}' contains invalid characters: '\\n', '\\r', or '\"'" end @file = file @line = line end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
33 34 35 |
# File 'lib/dbc/ocl.rb', line 33 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
33 34 35 |
# File 'lib/dbc/ocl.rb', line 33 def line @line end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
33 34 35 |
# File 'lib/dbc/ocl.rb', line 33 def @message end |
Instance Method Details
#to_s(context = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dbc/ocl.rb', line 35 def to_s(context = nil) if @file tag = "\"#{@file}:#{@line}: " else tag = " __FILE__ \":#{@line}: " end # C string is open tag << context << ': ' if context tag << ' ' << @message if @message tag << "\"" # close C string end |