Class: Examplify

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ Examplify

Returns a new instance of Examplify.



6
7
8
# File 'lib/examplify.rb', line 6

def initialize(paths)
  @files = Rake::FileList[get_list_of_files(paths)]
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



4
5
6
# File 'lib/examplify.rb', line 4

def files
  @files
end

Instance Method Details

#exclude(glob) ⇒ Object



10
11
12
13
14
# File 'lib/examplify.rb', line 10

def exclude(glob)
  files.exclude do |path|
    glob_matches_file(glob, path)
  end
end

#filter(glob) ⇒ Object

inverse of exclude



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

def filter(glob)
  files.exclude do |path|
    !glob_matches_file(glob, path)
  end
end

#outputObject



23
24
25
26
27
28
29
30
# File 'lib/examplify.rb', line 23

def output
  files.map { |path|
    title   = ["# ", path].join
    content = File.read(path)

    [title, content].join("\n")
  }.join("\n")
end