Class: Yoda::AST::CommentBlock::Token
- Inherits:
-
Object
- Object
- Yoda::AST::CommentBlock::Token
- Defined in:
- lib/yoda/ast/comment_block/token.rb
Instance Attribute Summary collapse
- #content ⇒ String readonly
- #range ⇒ Parsing::Range? readonly
Class Method Summary collapse
Instance Method Summary collapse
- #include?(location) ⇒ Boolean
-
#initialize(content, range:) ⇒ Token
constructor
A new instance of Token.
Constructor Details
#initialize(content, range:) ⇒ Token
Returns a new instance of Token.
31 32 33 34 |
# File 'lib/yoda/ast/comment_block/token.rb', line 31 def initialize(content, range:) @content = content @range = range end |
Instance Attribute Details
#content ⇒ String (readonly)
24 25 26 |
# File 'lib/yoda/ast/comment_block/token.rb', line 24 def content @content end |
#range ⇒ Parsing::Range? (readonly)
27 28 29 |
# File 'lib/yoda/ast/comment_block/token.rb', line 27 def range @range end |
Class Method Details
.from_parslet(slice, comment_block:) ⇒ CommentBlock::Slice
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/yoda/ast/comment_block/token.rb', line 10 def self.from_parslet(slice, comment_block:) begin_location = comment_block.location_from_index(slice.offset) end_location = comment_block.location_from_index(slice.offset + slice.length) range = if begin_location && end_location Parsing::Range.new(begin_location, end_location) else nil end new(slice.to_s, range: range) end |
Instance Method Details
#include?(location) ⇒ Boolean
38 39 40 |
# File 'lib/yoda/ast/comment_block/token.rb', line 38 def include?(location) range&.include?(location) end |