Class: YARP::RegularExpressionNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::RegularExpressionNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a regular expression literal with no interpolation.
/foo/i
^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location.
-
#content_loc ⇒ Object
readonly
attr_reader content_loc: Location.
-
#flags ⇒ Object
readonly
attr_reader flags: Integer.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
-
#unescaped ⇒ Object
readonly
attr_reader unescaped: String.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#ascii_8bit? ⇒ Boolean
def ascii_8bit?: () -> bool.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#content ⇒ Object
def content: () -> String.
-
#copy(**params) ⇒ Object
def copy: (**params) -> RegularExpressionNode.
- #deconstruct_keys(keys) ⇒ Object
-
#euc_jp? ⇒ Boolean
def euc_jp?: () -> bool.
-
#extended? ⇒ Boolean
def extended?: () -> bool.
-
#ignore_case? ⇒ Boolean
def ignore_case?: () -> bool.
-
#initialize(opening_loc, content_loc, closing_loc, unescaped, flags, location) ⇒ RegularExpressionNode
constructor
def initialize: (opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, flags: Integer, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#multi_line? ⇒ Boolean
def multi_line?: () -> bool.
-
#once? ⇒ Boolean
def once?: () -> bool.
-
#opening ⇒ Object
def opening: () -> String.
-
#utf_8? ⇒ Boolean
def utf_8?: () -> bool.
-
#windows_31j? ⇒ Boolean
def windows_31j?: () -> bool.
Constructor Details
#initialize(opening_loc, content_loc, closing_loc, unescaped, flags, location) ⇒ RegularExpressionNode
def initialize: (opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String, flags: Integer, location: Location) -> void
8518 8519 8520 8521 8522 8523 8524 8525 |
# File 'lib/yarp/node.rb', line 8518 def initialize(opening_loc, content_loc, closing_loc, unescaped, flags, location) @opening_loc = opening_loc @content_loc = content_loc @closing_loc = closing_loc @unescaped = unescaped @flags = flags @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
8509 8510 8511 |
# File 'lib/yarp/node.rb', line 8509 def closing_loc @closing_loc end |
#content_loc ⇒ Object (readonly)
attr_reader content_loc: Location
8506 8507 8508 |
# File 'lib/yarp/node.rb', line 8506 def content_loc @content_loc end |
#flags ⇒ Object (readonly)
attr_reader flags: Integer
8515 8516 8517 |
# File 'lib/yarp/node.rb', line 8515 def flags @flags end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
8503 8504 8505 |
# File 'lib/yarp/node.rb', line 8503 def opening_loc @opening_loc end |
#unescaped ⇒ Object (readonly)
attr_reader unescaped: String
8512 8513 8514 |
# File 'lib/yarp/node.rb', line 8512 def unescaped @unescaped end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
8528 8529 8530 |
# File 'lib/yarp/node.rb', line 8528 def accept(visitor) visitor.visit_regular_expression_node(self) end |
#ascii_8bit? ⇒ Boolean
def ascii_8bit?: () -> bool
8598 8599 8600 |
# File 'lib/yarp/node.rb', line 8598 def ascii_8bit? flags.anybits?(RegularExpressionFlags::ASCII_8BIT) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8533 8534 8535 |
# File 'lib/yarp/node.rb', line 8533 def child_nodes [] end |
#closing ⇒ Object
def closing: () -> String
8573 8574 8575 |
# File 'lib/yarp/node.rb', line 8573 def closing closing_loc.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
8538 8539 8540 |
# File 'lib/yarp/node.rb', line 8538 def comment_targets [opening_loc, content_loc, closing_loc] end |
#content ⇒ Object
def content: () -> String
8568 8569 8570 |
# File 'lib/yarp/node.rb', line 8568 def content content_loc.slice end |
#copy(**params) ⇒ Object
def copy: (**params) -> RegularExpressionNode
8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 |
# File 'lib/yarp/node.rb', line 8543 def copy(**params) RegularExpressionNode.new( params.fetch(:opening_loc) { opening_loc }, params.fetch(:content_loc) { content_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:unescaped) { unescaped }, params.fetch(:flags) { flags }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
8558 8559 8560 |
# File 'lib/yarp/node.rb', line 8558 def deconstruct_keys(keys) { opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, flags: flags, location: location } end |
#euc_jp? ⇒ Boolean
def euc_jp?: () -> bool
8593 8594 8595 |
# File 'lib/yarp/node.rb', line 8593 def euc_jp? flags.anybits?(RegularExpressionFlags::EUC_JP) end |
#extended? ⇒ Boolean
def extended?: () -> bool
8588 8589 8590 |
# File 'lib/yarp/node.rb', line 8588 def extended? flags.anybits?(RegularExpressionFlags::EXTENDED) end |
#ignore_case? ⇒ Boolean
def ignore_case?: () -> bool
8578 8579 8580 |
# File 'lib/yarp/node.rb', line 8578 def ignore_case? flags.anybits?(RegularExpressionFlags::IGNORE_CASE) end |
#inspect(inspector = NodeInspector.new) ⇒ Object
8617 8618 8619 8620 8621 8622 8623 8624 8625 |
# File 'lib/yarp/node.rb', line 8617 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" inspector << "├── content_loc: #{inspector.location(content_loc)}\n" inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n" inspector << "├── unescaped: #{unescaped.inspect}\n" inspector << "└── flags: #{[("ignore_case" if ignore_case?), ("multi_line" if multi_line?), ("extended" if extended?), ("euc_jp" if euc_jp?), ("ascii_8bit" if ascii_8bit?), ("windows_31j" if windows_31j?), ("utf_8" if utf_8?), ("once" if once?)].compact.join(", ")}\n" inspector.to_str end |
#multi_line? ⇒ Boolean
def multi_line?: () -> bool
8583 8584 8585 |
# File 'lib/yarp/node.rb', line 8583 def multi_line? flags.anybits?(RegularExpressionFlags::MULTI_LINE) end |
#once? ⇒ Boolean
def once?: () -> bool
8613 8614 8615 |
# File 'lib/yarp/node.rb', line 8613 def once? flags.anybits?(RegularExpressionFlags::ONCE) end |
#opening ⇒ Object
def opening: () -> String
8563 8564 8565 |
# File 'lib/yarp/node.rb', line 8563 def opening opening_loc.slice end |
#utf_8? ⇒ Boolean
def utf_8?: () -> bool
8608 8609 8610 |
# File 'lib/yarp/node.rb', line 8608 def utf_8? flags.anybits?(RegularExpressionFlags::UTF_8) end |
#windows_31j? ⇒ Boolean
def windows_31j?: () -> bool
8603 8604 8605 |
# File 'lib/yarp/node.rb', line 8603 def windows_31j? flags.anybits?(RegularExpressionFlags::WINDOWS_31J) end |