Skip to content

add parents and lineage methods #173

@doriantaylor

Description

@doriantaylor

I have a subclass of MimeMagic that I use that has a handful of useful methods:

  • .binary? will sample an input to determine if it's binary (or text)
  • .default_type will return application/octet-stream if the input is binary, text/plain otherwise
  • #parents will return the list of a type's immediate parents
  • #lineage will return a type's full list of ancestors

I also make a cursory affordance for type parameters in the constructor and inspect methods.

I'm filing this issue rather than coming in hot with a PR because I also change the behaviour of .by_magic and .all_by_magic, such that they will always return a value (the value of .default_type); I figured that merited some discussion. I'm happy to do the patch that addresses this and another issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions