class Prism::RationalNode

表示一个有理数文字。

1.0r
^^^^

属性

denominator[R]

有理数的分母。

1.5r # denominator 2
numerator[R]

有理数的分子。

1.5r # numerator 3

公共类方法

new(source, node_id, location, flags, numerator, denominator) 点击以切换源代码

初始化一个新的RationalNode节点。

# File prism/node.rb, line 15074
def initialize(source, node_id, location, flags, numerator, denominator)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @numerator = numerator
  @denominator = denominator
end
type() 点击以切换源代码

返回此节点类型的符号表示形式。请参阅“Node::type”。

# File prism/node.rb, line 15157
def self.type
  :rational_node
end

公共实例方法

===(other) 点击以切换源代码

为节点实现大小写相等性。这实际上是 ==,但不比较位置的值。位置仅检查是否存在。

# File prism/node.rb, line 15163
def ===(other)
  other.is_a?(RationalNode) &&
    (flags === other.flags) &&
    (numerator === other.numerator) &&
    (denominator === other.denominator)
end
accept(visitor) 点击以切换源代码

def accept: (Visitor visitor) -> void

# File prism/node.rb, line 15084
def accept(visitor)
  visitor.visit_rational_node(self)
end
binary?() 点击以切换源代码

def binary?: () -> bool

# File prism/node.rb, line 15117
def binary?
  flags.anybits?(IntegerBaseFlags::BINARY)
end
child_nodes() 点击以切换源代码

def child_nodes: () -> Array[nil | Node]

# File prism/node.rb, line 15089
def child_nodes
  []
end
也别名为:deconstruct
comment_targets() 点击以切换源代码

def comment_targets: () -> Array[Node | Location]

# File prism/node.rb, line 15099
def comment_targets
  [] #: Array[Prism::node | Location]
end
compact_child_nodes() 点击以切换源代码

def compact_child_nodes: () -> Array

# File prism/node.rb, line 15094
def compact_child_nodes
  []
end
copy(node_id: self.node_id, location: self.location, flags: self.flags, numerator: self.numerator, denominator: self.denominator) 点击以切换源代码

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?numerator: Integer, ?denominator: Integer) -> RationalNode

# File prism/node.rb, line 15104
def copy(node_id: self.node_id, location: self.location, flags: self.flags, numerator: self.numerator, denominator: self.denominator)
  RationalNode.new(source, node_id, location, flags, numerator, denominator)
end
decimal?() 点击以切换源代码

def decimal?: () -> bool

# File prism/node.rb, line 15122
def decimal?
  flags.anybits?(IntegerBaseFlags::DECIMAL)
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

别名为:child_nodes
deconstruct_keys(keys) 点击以切换源代码

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, numerator: Integer, denominator: Integer }

# File prism/node.rb, line 15112
def deconstruct_keys(keys)
  { node_id: node_id, location: location, numerator: numerator, denominator: denominator }
end
hexadecimal?() 点击以切换源代码

def hexadecimal?: () -> bool

# File prism/node.rb, line 15132
def hexadecimal?
  flags.anybits?(IntegerBaseFlags::HEXADECIMAL)
end
inspect() 点击以切换源代码

def inspect -> String

# File prism/node.rb, line 15147
def inspect
  InspectVisitor.compose(self)
end
numeric() 点击以切换源代码

返回节点的值作为 IntegerNodeFloatNode。此方法已被弃用,建议使用 valuenumerator/#denominator。

# File prism/node_ext.rb, line 120
def numeric
  deprecated("value", "numerator", "denominator")

  if denominator == 1
    IntegerNode.new(source, -1, location.chop, flags, numerator)
  else
    FloatNode.new(source, -1, location.chop, 0, numerator.to_f / denominator)
  end
end
octal?() 点击以切换源代码

def octal?: () -> bool

# File prism/node.rb, line 15127
def octal?
  flags.anybits?(IntegerBaseFlags::OCTAL)
end
type() 点击以切换源代码

返回此节点类型的符号表示形式。请参阅“Node#type”。

# File prism/node.rb, line 15152
def type
  :rational_node
end
value() 点击以切换源代码

返回节点的值作为 Ruby Rational。

# File prism/node_ext.rb, line 114
def value
  Rational(numerator, denominator)
end