Class: Prism::MatchLastLineNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::MatchLastLineNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
sig/generated/prism/node.rbs,
sig/generated/prism/node_ext.rbs,
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
^^^^^^
Class Method Summary collapse
-
.type ⇒ :match_last_line_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#ascii_8bit? ⇒ Boolean
:category: Flags n - forces the ASCII-8BIT encoding.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#closing ⇒ String
:call-seq: closing -> String.
-
#closing_loc ⇒ Location
:category: Locations :call-seq: closing_loc -> Location.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#content ⇒ String
:call-seq: content -> String.
-
#content_loc ⇒ Location
:category: Locations :call-seq: 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) ⇒ MatchLastLineNode
:call-seq: copy(**fields) -> MatchLastLineNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#euc_jp? ⇒ Boolean
:category: Flags e - forces the EUC-JP encoding.
-
#extended? ⇒ Boolean
:category: Flags x - ignores whitespace and allows comments in regular expressions.
-
#forced_binary_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to binary.
-
#forced_us_ascii_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to US-ASCII.
-
#forced_utf8_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to UTF-8.
-
#ignore_case? ⇒ Boolean
:category: Flags i - ignores the case of characters when matching.
-
#initialize(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped) ⇒ MatchLastLineNode
constructor
Initialize a new MatchLastLineNode node.
-
#inspect ⇒ String
: () -> String.
-
#multi_line? ⇒ Boolean
:category: Flags m - allows $ to match the end of lines within strings.
-
#once? ⇒ Boolean
:category: Flags o - only interpolates values into the regular expression once.
-
#opening ⇒ String
:call-seq: opening -> String.
-
#opening_loc ⇒ Location
:category: Locations :call-seq: opening_loc -> Location.
-
#options ⇒ Integer
Returns a numeric value that represents the flags that were used to create the regular expression.
-
#save_closing_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the closing_loc location using the given saved source so that it can be retrieved later.
-
#save_content_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the content_loc location using the given saved source so that it can be retrieved later.
-
#save_opening_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the opening_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :match_last_line_node
See
Node#type. -
#unescaped ⇒ String
:call-seq: unescaped -> String.
-
#utf_8? ⇒ Boolean
:category: Flags u - forces the UTF-8 encoding.
-
#windows_31j? ⇒ Boolean
:category: Flags s - forces the Windows-31J encoding.
Constructor Details
#initialize(source, node_id, location, flags, opening_loc, content_loc, closing_loc, unescaped) ⇒ MatchLastLineNode
Initialize a new MatchLastLineNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void
22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 |
# File 'lib/prism/node.rb', line 22649 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 |
Class Method Details
.type ⇒ :match_last_line_node
See Node.type.
: () -> :match_last_line_node
22742 22743 22744 |
# File 'lib/prism/node.rb', line 22742 def self.type :match_last_line_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
22952 22953 22954 22955 22956 22957 22958 22959 |
# File 'lib/prism/node.rb', line 22952 def ===(other) # :nodoc: 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
See Node.accept.
: (_Visitor visitor) -> untyped
22674 22675 22676 |
# File 'lib/prism/node.rb', line 22674 def accept(visitor) visitor.visit_match_last_line_node(self) end |
#ascii_8bit? ⇒ Boolean
:category: Flags n - forces the ASCII-8BIT encoding
: () -> bool
22797 22798 22799 |
# File 'lib/prism/node.rb', line 22797 def ascii_8bit? flags.anybits?(RegularExpressionFlags::ASCII_8BIT) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
22681 22682 22683 |
# File 'lib/prism/node.rb', line 22681 def child_nodes [] end |
#closing ⇒ String
:call-seq:
closing -> String
Slice the location of closing_loc from the source.
: () -> String
22945 22946 22947 |
# File 'lib/prism/node.rb', line 22945 def closing closing_loc.slice end |
#closing_loc ⇒ Location
:category: Locations :call-seq:
closing_loc -> Location
Returns the Location represented by closing_loc.
: () -> Location
22892 22893 22894 22895 22896 |
# File 'lib/prism/node.rb', line 22892 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
22697 22698 22699 |
# File 'lib/prism/node.rb', line 22697 def compact_child_nodes [] end |
#content ⇒ String
:call-seq:
content -> String
Slice the location of content_loc from the source.
: () -> String
22935 22936 22937 |
# File 'lib/prism/node.rb', line 22935 def content content_loc.slice end |
#content_loc ⇒ Location
:category: Locations :call-seq:
content_loc -> Location
Returns the Location represented by content_loc.
: () -> Location
22870 22871 22872 22873 22874 |
# File 'lib/prism/node.rb', line 22870 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) ⇒ MatchLastLineNode
:call-seq:
copy(**fields) -> MatchLastLineNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode
22707 22708 22709 |
# File 'lib/prism/node.rb', line 22707 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) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 |
# File 'lib/prism/node.rb', line 22714 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location opening_loc content_loc closing_loc unescaped opening content closing]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :opening_loc then deconstructed[:opening_loc] = self.opening_loc when :content_loc then deconstructed[:content_loc] = self.content_loc when :closing_loc then deconstructed[:closing_loc] = self.closing_loc when :unescaped then deconstructed[:unescaped] = self.unescaped when :opening then deconstructed[:opening] = self.opening when :content then deconstructed[:content] = self.content when :closing then deconstructed[:closing] = self.closing end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
22689 22690 22691 22692 |
# File 'lib/prism/node.rb', line 22689 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? end |
#euc_jp? ⇒ Boolean
:category: Flags e - forces the EUC-JP encoding
: () -> bool
22789 22790 22791 |
# File 'lib/prism/node.rb', line 22789 def euc_jp? flags.anybits?(RegularExpressionFlags::EUC_JP) end |
#extended? ⇒ Boolean
:category: Flags x - ignores whitespace and allows comments in regular expressions
: () -> bool
22765 22766 22767 |
# File 'lib/prism/node.rb', line 22765 def extended? flags.anybits?(RegularExpressionFlags::EXTENDED) end |
#forced_binary_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to binary
: () -> bool
22829 22830 22831 |
# File 'lib/prism/node.rb', line 22829 def forced_binary_encoding? flags.anybits?(RegularExpressionFlags::FORCED_BINARY_ENCODING) end |
#forced_us_ascii_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to US-ASCII
: () -> bool
22837 22838 22839 |
# File 'lib/prism/node.rb', line 22837 def forced_us_ascii_encoding? flags.anybits?(RegularExpressionFlags::FORCED_US_ASCII_ENCODING) end |
#forced_utf8_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to UTF-8
: () -> bool
22821 22822 22823 |
# File 'lib/prism/node.rb', line 22821 def forced_utf8_encoding? flags.anybits?(RegularExpressionFlags::FORCED_UTF8_ENCODING) end |
#ignore_case? ⇒ Boolean
:category: Flags i - ignores the case of characters when matching
: () -> bool
22757 22758 22759 |
# File 'lib/prism/node.rb', line 22757 def ignore_case? flags.anybits?(RegularExpressionFlags::IGNORE_CASE) end |
#inspect ⇒ String
: () -> String
22747 22748 22749 |
# File 'lib/prism/node.rb', line 22747 def inspect # :nodoc: InspectVisitor.compose(self) end |
#multi_line? ⇒ Boolean
:category: Flags m - allows $ to match the end of lines within strings
: () -> bool
22773 22774 22775 |
# File 'lib/prism/node.rb', line 22773 def multi_line? flags.anybits?(RegularExpressionFlags::MULTI_LINE) end |
#once? ⇒ Boolean
:category: Flags o - only interpolates values into the regular expression once
: () -> bool
22781 22782 22783 |
# File 'lib/prism/node.rb', line 22781 def once? flags.anybits?(RegularExpressionFlags::ONCE) end |
#opening ⇒ String
:call-seq:
opening -> String
Slice the location of opening_loc from the source.
: () -> String
22925 22926 22927 |
# File 'lib/prism/node.rb', line 22925 def opening opening_loc.slice end |
#opening_loc ⇒ Location
:category: Locations :call-seq:
opening_loc -> Location
Returns the Location represented by opening_loc.
: () -> Location
22848 22849 22850 22851 22852 |
# File 'lib/prism/node.rb', line 22848 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#options ⇒ Integer
Returns a numeric value that represents the flags that were used to create the regular expression.
: () -> Integer
66 67 68 |
# File 'lib/prism/node_ext.rb', line 66 def RegularExpressionOptions.(flags) end |
#save_closing_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the closing_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
22903 22904 22905 |
# File 'lib/prism/node.rb', line 22903 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end |
#save_content_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the content_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
22881 22882 22883 |
# File 'lib/prism/node.rb', line 22881 def save_content_loc(repository) repository.enter(node_id, :content_loc) end |
#save_opening_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the opening_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
22859 22860 22861 |
# File 'lib/prism/node.rb', line 22859 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#type ⇒ :match_last_line_node
See Node#type.
: () -> :match_last_line_node
22735 22736 22737 |
# File 'lib/prism/node.rb', line 22735 def type :match_last_line_node end |
#unescaped ⇒ String
:call-seq:
unescaped -> String
Returns the unescaped attribute.
: () -> String
22913 22914 22915 |
# File 'lib/prism/node.rb', line 22913 def unescaped @unescaped end |
#utf_8? ⇒ Boolean
:category: Flags u - forces the UTF-8 encoding
: () -> bool
22813 22814 22815 |
# File 'lib/prism/node.rb', line 22813 def utf_8? flags.anybits?(RegularExpressionFlags::UTF_8) end |
#windows_31j? ⇒ Boolean
:category: Flags s - forces the Windows-31J encoding
: () -> bool
22805 22806 22807 |
# File 'lib/prism/node.rb', line 22805 def windows_31j? flags.anybits?(RegularExpressionFlags::WINDOWS_31J) end |