Sha256: ea2bfcf2bf48e95da11bef261fe5ed6badc5e92217701d8dd393d84ac3de5a6a

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

#!/usr/bin/env fancy
# -*- fancy -*-

try {
  if: (ARGV[1]) then: {
    ident = ARGV rest join: " "
    documentation = nil
    match ident {
      case /##/ ->
        parts = ident split: "##"
        obj = parts[0] eval
        if: (parts[1]) then: |method_name| {
          method = obj method: method_name
          documentation = method documentation
        }
      case /#/ ->
        parts = ident split: "#"
        obj = parts[0] eval
        if: (parts[1]) then: |method_name| {
          method = nil
          try {
            method = obj instance_method: method_name
          } catch NoMethodError {
            # handle singleton methods if ARGV[1] is a singleton
            method = obj method: method_name
          }
          documentation = method documentation
        }
      case _ ->
        obj = ident eval
        documentation = obj documentation
    }

    "Documentation for: '#{ident}':" println
    documentation println
  } else: {
    ["Prints the documentation string for a given object or one if its methods",
     "Usage:",
     "fyi [ObjectIdentifier]",
     "fyi [ObjectIdentifier]#[MethodName]",
     "",
     "Example: fyi Array#each:"] println
  }
} catch Exception => e {
  "ERROR: #{e message}" println
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fancy-0.10.0 bin/fyi
fancy-0.9.0 bin/fyi
fancy-0.8.0 bin/fyi
fancy-0.7.0 bin/fyi
fancy-0.6.0 bin/fyi
fancy-0.5.0 bin/fyi
fancy-0.4.0 bin/fyi