Module: Sevgi::Function

Extended by:
Color, File, Math, Pluralize, Shell, String, UI
Defined in:
lib/sevgi/function.rb,
lib/sevgi/function/ui.rb,
lib/sevgi/function/file.rb,
lib/sevgi/function/math.rb,
lib/sevgi/function/color.rb,
lib/sevgi/function/shell.rb,
lib/sevgi/function/locate.rb,
lib/sevgi/function/string.rb,
lib/sevgi/function/version.rb

Overview

Support toolbox for Sevgi components and advanced extensions. The supported helper facade is F; it provides degree-based trigonometry and precision, file discovery and output, argv-safe commands, naming helpers, and small terminal status tools. It is not intended as a general-purpose utility library.

Location, Locate, and Shell::Result are public supporting values. The thread-local precision accessors remain on Math.precision. Other nested helper modules organize the facade implementation and its method documentation; consumers should not include or extend them.

Examples:

Use the supported facade in library code

Sevgi::F.with_precision(3) do
  Sevgi::F.cos(60)
  Sevgi::F.approx(1.0 / 3)
end

See Also:

Defined Under Namespace

Modules: Color, File, Math, Pluralize, Shell, String, UI Classes: Locate, Location

Constant Summary collapse

VERSION =

Current version of the Sevgi function gem.

"0.98.2"

Constants included from Math

Math::PRECISION

Class Method Summary collapse

Methods included from UI

do, mayok, notok, ok, ui

Methods included from File

changed?, existing, existing!, existing_map, existing_map!, out, qualify, subext, touch

Methods included from Math

acos, acot, approx, asin, atan, atan2, cos, cot, count, eq?, ge?, gt?, le?, lt?, precision, precision=, round, sin, tan, to_degrees, to_radians, with_precision, zero?

Methods included from Color

blue, bold, cyan, dim, green, magenta, red, yellow

Methods included from Shell

executable!, executable?, sh, sh!

Methods included from String

demodulize

Methods included from Pluralize

pluralize

Class Method Details

.locate(filename, start, exclude: nil, extension: EXTENSION) ⇒ Sevgi::Function::Location

Locates a Sevgi-related file by walking upward from a start directory.

Parameters:

  • filename (String)

    file name or extensionless basename

  • start (String)

    directory where lookup starts

  • exclude (Array<String>, String, nil) (defaults to: nil)

    paths ignored during lookup

  • extension (String) (defaults to: EXTENSION)

    default extension added before lookup

Returns:

Raises:

  • (Sevgi::Error)

    when no matching file exists

  • (Errno::ENOENT)

    when the start directory does not exist

  • (Errno::ENOTDIR)

    when the start path is not a directory



130
131
132
133
134
# File 'lib/sevgi/function/locate.rb', line 130

def self.locate(filename, start, exclude: nil, extension: EXTENSION)
  Locate.(F.qualify(filename, extension), start, exclude:).tap do |path|
    Error.("Cannot load a file matching: #{filename}") unless path
  end
end