Class: Prism::MatchLastLineNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::MatchLastLineNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
ext/prism/api_node.c
Overview
Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object.
if /foo/i then end
^^^^^^
Instance Attribute Summary collapse
-
#unescaped ⇒ Object
readonly
attr_reader unescaped: String.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#ascii_8bit? ⇒ Boolean
def ascii_8bit?: () -> bool.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#closing ⇒ Object
def closing: () -> String.
-
#closing_loc ⇒ Object
attr_reader closing_loc: Location.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#content ⇒ Object
def content: () -> String.
-
#content_loc ⇒ Object
attr_reader content_loc: Location.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, content_loc: self.content_loc, closing_loc: self.closing_loc, unescaped: self.unescaped) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String }.
-
#euc_jp? ⇒ Boolean
def euc_jp?: () -> bool.
-
#extended? ⇒ Boolean
def extended?: () -> bool.
-
#forced_binary_encoding? ⇒ Boolean
def forced_binary_encoding?: () -> bool.
-
#forced_us_ascii_encoding? ⇒ Boolean
def forced_us_ascii_encoding?: () -> bool.
-
#forced_utf8_encoding? ⇒ Boolean
def forced_utf8_encoding?: () -> bool.
-
#ignore_case? ⇒ Boolean
def ignore_case?: () -> bool.
-
#initialize(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped) ⇒ MatchLastLineNode
constructor
Initialize a new MatchLastLineNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#multi_line? ⇒ Boolean
def multi_line?: () -> bool.
-
#once? ⇒ Boolean
def once?: () -> bool.
-
#opening ⇒ Object
def opening: () -> String.
-
#opening_loc ⇒ Object
attr_reader opening_loc: Location.
-
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
-
#save_content_loc(repository) ⇒ Object
Save the content_loc location using the given saved source so that it can be retrieved later.
-
#save_opening_loc(repository) ⇒ Object
Save the opening_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
-
#utf_8? ⇒ Boolean
def utf_8?: () -> bool.
-
#windows_31j? ⇒ Boolean
def windows_31j?: () -> bool.
Constructor Details
#initialize(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped) ⇒ MatchLastLineNode
Initialize a new MatchLastLineNode node.
12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 |
# File 'lib/prism/node.rb', line 12493 def initialize(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped) @source = source @node_id = node_id @location = location @flags = flags @opening_loc = opening_loc @content_loc = content_loc @closing_loc = closing_loc @unescaped = unescaped end |
Instance Attribute Details
#unescaped ⇒ Object (readonly)
attr_reader unescaped: String
12632 12633 12634 |
# File 'lib/prism/node.rb', line 12632 def unescaped @unescaped end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
12660 12661 12662 |
# File 'lib/prism/node.rb', line 12660 def self.type :match_last_line_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
12666 12667 12668 12669 12670 12671 12672 12673 |
# File 'lib/prism/node.rb', line 12666 def ===(other) other.is_a?(MatchLastLineNode) && (flags === other.flags) && (opening_loc.nil? == other.opening_loc.nil?) && (content_loc.nil? == other.content_loc.nil?) && (closing_loc.nil? == other.closing_loc.nil?) && (unescaped === other.unescaped) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
12505 12506 12507 |
# File 'lib/prism/node.rb', line 12505 def accept(visitor) visitor.visit_match_last_line_node(self) end |
#ascii_8bit? ⇒ Boolean
def ascii_8bit?: () -> bool
12563 12564 12565 |
# File 'lib/prism/node.rb', line 12563 def ascii_8bit? flags.anybits?(RegularExpressionFlags::ASCII_8BIT) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
12510 12511 12512 |
# File 'lib/prism/node.rb', line 12510 def child_nodes [] end |
#closing ⇒ Object
def closing: () -> String
12645 12646 12647 |
# File 'lib/prism/node.rb', line 12645 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
12619 12620 12621 12622 12623 |
# File 'lib/prism/node.rb', line 12619 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
12520 12521 12522 |
# File 'lib/prism/node.rb', line 12520 def comment_targets [opening_loc, content_loc, closing_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
12515 12516 12517 |
# File 'lib/prism/node.rb', line 12515 def compact_child_nodes [] end |
#content ⇒ Object
def content: () -> String
12640 12641 12642 |
# File 'lib/prism/node.rb', line 12640 def content content_loc.slice end |
#content_loc ⇒ Object
attr_reader content_loc: Location
12606 12607 12608 12609 12610 |
# File 'lib/prism/node.rb', line 12606 def content_loc location = @content_loc return location if location.is_a?(Location) @content_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, content_loc: self.content_loc, closing_loc: self.closing_loc, unescaped: self.unescaped) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode
12525 12526 12527 |
# File 'lib/prism/node.rb', line 12525 def copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, content_loc: self.content_loc, closing_loc: self.closing_loc, unescaped: self.unescaped) MatchLastLineNode.new(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location, content_loc: Location, closing_loc: Location, unescaped: String }
12533 12534 12535 |
# File 'lib/prism/node.rb', line 12533 def deconstruct_keys(keys) { node_id: node_id, location: location, opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped } end |
#euc_jp? ⇒ Boolean
def euc_jp?: () -> bool
12558 12559 12560 |
# File 'lib/prism/node.rb', line 12558 def euc_jp? flags.anybits?(RegularExpressionFlags::EUC_JP) end |
#extended? ⇒ Boolean
def extended?: () -> bool
12543 12544 12545 |
# File 'lib/prism/node.rb', line 12543 def extended? flags.anybits?(RegularExpressionFlags::EXTENDED) end |
#forced_binary_encoding? ⇒ Boolean
def forced_binary_encoding?: () -> bool
12583 12584 12585 |
# File 'lib/prism/node.rb', line 12583 def forced_binary_encoding? flags.anybits?(RegularExpressionFlags::FORCED_BINARY_ENCODING) end |
#forced_us_ascii_encoding? ⇒ Boolean
def forced_us_ascii_encoding?: () -> bool
12588 12589 12590 |
# File 'lib/prism/node.rb', line 12588 def forced_us_ascii_encoding? flags.anybits?(RegularExpressionFlags::FORCED_US_ASCII_ENCODING) end |
#forced_utf8_encoding? ⇒ Boolean
def forced_utf8_encoding?: () -> bool
12578 12579 12580 |
# File 'lib/prism/node.rb', line 12578 def forced_utf8_encoding? flags.anybits?(RegularExpressionFlags::FORCED_UTF8_ENCODING) end |
#ignore_case? ⇒ Boolean
def ignore_case?: () -> bool
12538 12539 12540 |
# File 'lib/prism/node.rb', line 12538 def ignore_case? flags.anybits?(RegularExpressionFlags::IGNORE_CASE) end |
#inspect ⇒ Object
def inspect -> String
12650 12651 12652 |
# File 'lib/prism/node.rb', line 12650 def inspect InspectVisitor.compose(self) end |
#multi_line? ⇒ Boolean
def multi_line?: () -> bool
12548 12549 12550 |
# File 'lib/prism/node.rb', line 12548 def multi_line? flags.anybits?(RegularExpressionFlags::MULTI_LINE) end |
#once? ⇒ Boolean
def once?: () -> bool
12553 12554 12555 |
# File 'lib/prism/node.rb', line 12553 def once? flags.anybits?(RegularExpressionFlags::ONCE) end |
#opening ⇒ Object
def opening: () -> String
12635 12636 12637 |
# File 'lib/prism/node.rb', line 12635 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
12593 12594 12595 12596 12597 |
# File 'lib/prism/node.rb', line 12593 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
12627 12628 12629 |
# File 'lib/prism/node.rb', line 12627 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end |
#save_content_loc(repository) ⇒ Object
Save the content_loc location using the given saved source so that it can be retrieved later.
12614 12615 12616 |
# File 'lib/prism/node.rb', line 12614 def save_content_loc(repository) repository.enter(node_id, :content_loc) end |
#save_opening_loc(repository) ⇒ Object
Save the opening_loc location using the given saved source so that it can be retrieved later.
12601 12602 12603 |
# File 'lib/prism/node.rb', line 12601 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
12655 12656 12657 |
# File 'lib/prism/node.rb', line 12655 def type :match_last_line_node end |
#utf_8? ⇒ Boolean
def utf_8?: () -> bool
12573 12574 12575 |
# File 'lib/prism/node.rb', line 12573 def utf_8? flags.anybits?(RegularExpressionFlags::UTF_8) end |
#windows_31j? ⇒ Boolean
def windows_31j?: () -> bool
12568 12569 12570 |
# File 'lib/prism/node.rb', line 12568 def windows_31j? flags.anybits?(RegularExpressionFlags::WINDOWS_31J) end |