class Ignore::File

Overview

Represents an ignore file (like .gitignore) that can be read, modified, and saved

Included Modules

Defined in:

ignore/file.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(path : String, create : Bool = true) #

Initialize from a file path By default, creates empty if file doesn't exist Set create: false to raise if file doesn't exist


Instance Method Detail

def add(pattern : String) : self #

Add a pattern (appends to end)


def clear : self #

Remove all lines (patterns, comments, and blanks)


def each(& : String -> ) : Nil #

Iterate over pattern strings (Enumerable support)


def empty? : Bool #

Check if there are no patterns


def ignores?(path : String) : Bool #

Check if a path should be ignored


def includes?(pattern : String) : Bool #

Check if a pattern exists


def lines : Array(String) #

All lines including comments and blank lines


def path : String #

The file path


def patterns : Array(String) #

Only pattern lines (excludes comments and blank lines)


def reload : self #

Reload from disk (discards unsaved changes)


def remove(pattern : String) : self #

Remove a pattern (first occurrence)


def save(path : String = @path) : self #

Save to file (original path or specified path)


def size : Int32 #

Number of patterns (excludes comments and blank lines)