Class: Oxc::Label
- Inherits:
-
Object
- Object
- Oxc::Label
- Defined in:
- lib/oxc/diagnostic.rb,
sig/oxc/diagnostic.rbs
Instance Attribute Summary collapse
- #finish ⇒ Integer readonly
- #message ⇒ String? readonly
- #start ⇒ Integer readonly
Class Method Summary collapse
-
.from_hash(parsed) ⇒ Oxc::Label
: (Hash[String, untyped]) -> Oxc::Label.
Instance Method Summary collapse
-
#initialize(start:, finish:, message: nil) ⇒ Label
constructor
: (start: Integer, finish: Integer, ?message: String?) -> void.
-
#inspect ⇒ String
: () -> String.
-
#slice(source) ⇒ String?
: (String) -> String?.
Constructor Details
#initialize(start:, finish:, message: nil) ⇒ Label
: (start: Integer, finish: Integer, ?message: String?) -> void
68 69 70 71 72 73 74 |
# File 'lib/oxc/diagnostic.rb', line 68 def initialize(start:, finish:, message: nil) @start = start @finish = finish @message = freeze end |
Instance Attribute Details
#finish ⇒ Integer (readonly)
60 61 62 |
# File 'lib/oxc/diagnostic.rb', line 60 def finish @finish end |
#message ⇒ String? (readonly)
58 59 60 |
# File 'lib/oxc/diagnostic.rb', line 58 def @message end |
#start ⇒ Integer (readonly)
59 60 61 |
# File 'lib/oxc/diagnostic.rb', line 59 def start @start end |
Class Method Details
.from_hash(parsed) ⇒ Oxc::Label
: (Hash[String, untyped]) -> Oxc::Label
63 64 65 |
# File 'lib/oxc/diagnostic.rb', line 63 def self.from_hash(parsed) new(message: parsed["message"], start: parsed.fetch("start"), finish: parsed.fetch("end")) end |
Instance Method Details
#inspect ⇒ String
: () -> String
82 83 84 |
# File 'lib/oxc/diagnostic.rb', line 82 def inspect "#<#{self.class.name} range=[#{start}, #{finish}]#{" #{.inspect}" if }>" end |
#slice(source) ⇒ String?
: (String) -> String?
77 78 79 |
# File 'lib/oxc/diagnostic.rb', line 77 def slice(source) source.byteslice(start, finish - start) end |