Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2016 08:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jreidinger/3883aa68662e9a7fdc7b to your computer and use it in GitHub Desktop.
disks = a_devicegraph.disks # A disks object, Array on steroids
disks = disks.with(name: ["/dev/sda", "/dev/sdb"]) # another disks object
primary_parts = disks.partitions.with(type: :primary) # A Partitions object, another Array on steroids
parts = disks.partitions.with(name: ["/dev/sda2", "/dev/sdc3"])
# equivalent line
# parts = a_devicegraph.disks.partitions.with(name: ["/dev/sda2", "/dev/sdc3"])
# Calls to whatever.filesystems returns a Filesystems object which is another Array on steroids
# So the equivalent to previous example ( would be
a_device_graph.filesystems.to_a # all file systems in the devicegraph
disks.filesystems.to_a # Filesystems in the chosen disks
primary_parts.filesystems.to_a # fs in primary parts of chosen disks
parts.filesystems.to_a # Filesystems in sda2 and sdc3
# But you don't need to use #to_a immediately (or at all)
part_fine_query.filesystems.with(label: "bla").first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment