class ActionDispatch::Journey::GTG::Builder

def nullable?(node)

Experimental RBS support (using type sampling data from the type_fusion project).

type ActionDispatch__Journey__GTG__Builder_nullable?_node = ActionDispatch::Journey::Nodes::Cat | ActionDispatch::Journey::Nodes::Symbol | ActionDispatch::Journey::Nodes::Slash | ActionDispatch::Journey::Nodes::Literal | ActionDispatch::Journey::Nodes::Group | ActionDispatch::Journey::Nodes::Dummy | ActionDispatch::Journey::Nodes::Dot

def nullable?: (ActionDispatch__Journey__GTG__Builder_nullable?_node node) -> untyped

This signature was generated using 271 samples from 1 application.

def nullable?(node)
  case node
  when Nodes::Group
    true
  when Nodes::Star
    # the default star regex is /(.+)/ which is NOT nullable
    # but since different constraints can be provided we must
    # actually check if this is the case or not.
    node.regexp.match?("")
  when Nodes::Or
    node.children.any? { |c| nullable?(c) }
  when Nodes::Cat
    nullable?(node.left) && nullable?(node.right)
  when Nodes::Terminal
    !node.left
  when Nodes::Unary
    nullable?(node.left)
  else
    raise ArgumentError, "unknown nullable: %s" % node.class.name
  end
end