Last constant of a ``constant`` or ``scope_resolution`` (``A::B::C`` -> ``C``).
(node, source: bytes)
| 3361 | |
| 3362 | |
| 3363 | def _ruby_const_last_name(node, source: bytes) -> str: |
| 3364 | """Last constant of a ``constant`` or ``scope_resolution`` (``A::B::C`` -> ``C``).""" |
| 3365 | if node is None: |
| 3366 | return "" |
| 3367 | if node.type == "constant": |
| 3368 | return _read_text(node, source) |
| 3369 | if node.type == "scope_resolution": |
| 3370 | consts = [c for c in node.children if c.type == "constant"] |
| 3371 | if consts: |
| 3372 | return _read_text(consts[-1], source) |
| 3373 | return "" |
| 3374 | |
| 3375 | |
| 3376 | # `Const = <factory>(...)` shapes that define a lightweight class named after the |
no test coverage detected