class Prism::KeywordHashNode

表示一个没有开闭花括号的哈希字面量。

foo(a: b)
    ^^^^

属性

elements[R]

attr_reader elements: Array[AssocNode | AssocSplatNode]

公共类方法

new(source, node_id, location, flags, elements) 点击切换源代码

初始化一个新的 KeywordHashNode 节点。

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

返回此节点类型的符号表示。请参阅 ‘Node::type`。

# File prism/node.rb, line 11395
def self.type
  :keyword_hash_node
end

公共实例方法

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

为节点实现 case-equality。 这实际上是 ==,但不比较 location 的值。仅检查 location 是否存在。

# File prism/node.rb, line 11401
def ===(other)
  other.is_a?(KeywordHashNode) &&
    (flags === other.flags) &&
    (elements.length == other.elements.length) &&
    elements.zip(other.elements).all? { |left, right| left === right }
end
accept(visitor) 点击切换源代码

def accept: (Visitor visitor) -> void

# File prism/node.rb, line 11344
def accept(visitor)
  visitor.visit_keyword_hash_node(self)
end
child_nodes() 点击切换源代码

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

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

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

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

def compact_child_nodes: () -> Array

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

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[AssocNode | AssocSplatNode]) -> KeywordHashNode

# File prism/node.rb, line 11364
def copy(node_id: self.node_id, location: self.location, flags: self.flags, elements: self.elements)
  KeywordHashNode.new(source, node_id, location, flags, elements)
end
deconstruct()

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

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

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, elements: Array[AssocNode | AssocSplatNode] }

# File prism/node.rb, line 11372
def deconstruct_keys(keys)
  { node_id: node_id, location: location, elements: elements }
end
inspect() 点击切换源代码

def inspect -> String

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

def symbol_keys?: () -> bool

# File prism/node.rb, line 11377
def symbol_keys?
  flags.anybits?(KeywordHashNodeFlags::SYMBOL_KEYS)
end
type() 点击切换源代码

返回此节点类型的符号表示。请参阅 ‘Node#type`。

# File prism/node.rb, line 11390
def type
  :keyword_hash_node
end