Class: Snipcheat::SnippetDir

Inherits:
Object
  • Object
show all
Defined in:
lib/snipcheat/snippet_dir.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SnippetDir

Returns a new instance of SnippetDir.



5
6
7
# File 'lib/snipcheat/snippet_dir.rb', line 5

def initialize(path)
  @path = path
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/snipcheat/snippet_dir.rb', line 9

def empty?
  filenames.empty?
end

#filenamesObject



17
18
19
20
21
# File 'lib/snipcheat/snippet_dir.rb', line 17

def filenames
  @_filenames ||= Dir.new(@path).select{ |x|
    x.end_with? '.sublime-snippet'
  }.compact
end

#snippetsObject



13
14
15
# File 'lib/snipcheat/snippet_dir.rb', line 13

def snippets
  @_snippets ||= filenames.map{ |fn| Snippet.new(File.join(@path, fn)) }
end