Class: Oxc::Comment
- Inherits:
-
Object
- Object
- Oxc::Comment
- Defined in:
- lib/oxc/parse_result.rb,
sig/oxc/parse_result.rbs
Constant Summary collapse
- LINE =
"Line"- BLOCK =
"Block"
Instance Attribute Summary collapse
- #finish ⇒ Integer readonly
- #start ⇒ Integer readonly
- #type ⇒ String readonly
- #value ⇒ String readonly
Class Method Summary collapse
-
.from_hash(parsed) ⇒ Oxc::Comment
: (Hash[String, untyped]) -> Oxc::Comment.
Instance Method Summary collapse
-
#block? ⇒ Boolean
: () -> bool.
-
#initialize(type:, value:, start:, finish:) ⇒ Comment
constructor
: (type: String, value: String, start: Integer, finish: Integer) -> void.
-
#inspect ⇒ String
: () -> String.
-
#line? ⇒ Boolean
: () -> bool.
-
#slice(source) ⇒ String?
: (String) -> String?.
Constructor Details
#initialize(type:, value:, start:, finish:) ⇒ Comment
: (type: String, value: String, start: Integer, finish: Integer) -> void
87 88 89 90 91 92 93 94 |
# File 'lib/oxc/parse_result.rb', line 87 def initialize(type:, value:, start:, finish:) @type = type @value = value @start = start @finish = finish freeze end |
Instance Attribute Details
#finish ⇒ Integer (readonly)
74 75 76 |
# File 'lib/oxc/parse_result.rb', line 74 def finish @finish end |
#start ⇒ Integer (readonly)
73 74 75 |
# File 'lib/oxc/parse_result.rb', line 73 def start @start end |
#type ⇒ String (readonly)
71 72 73 |
# File 'lib/oxc/parse_result.rb', line 71 def type @type end |
#value ⇒ String (readonly)
72 73 74 |
# File 'lib/oxc/parse_result.rb', line 72 def value @value end |
Class Method Details
.from_hash(parsed) ⇒ Oxc::Comment
: (Hash[String, untyped]) -> Oxc::Comment
77 78 79 80 81 82 83 84 |
# File 'lib/oxc/parse_result.rb', line 77 def self.from_hash(parsed) new( type: parsed.fetch("type"), value: parsed.fetch("value"), start: parsed.fetch("start"), finish: parsed.fetch("end") ) end |
Instance Method Details
#block? ⇒ Boolean
: () -> bool
102 103 104 |
# File 'lib/oxc/parse_result.rb', line 102 def block? type == BLOCK end |
#inspect ⇒ String
: () -> String
112 113 114 |
# File 'lib/oxc/parse_result.rb', line 112 def inspect "#<#{self.class.name} #{type} #{value.inspect}>" end |
#line? ⇒ Boolean
: () -> bool
97 98 99 |
# File 'lib/oxc/parse_result.rb', line 97 def line? type == LINE end |
#slice(source) ⇒ String?
: (String) -> String?
107 108 109 |
# File 'lib/oxc/parse_result.rb', line 107 def slice(source) source.byteslice(start, finish - start) end |