Class: Fontist::CollectionFile

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/fontist/collection_file.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ttfunk_collection) ⇒ CollectionFile

Returns a new instance of CollectionFile.



26
27
28
# File 'lib/fontist/collection_file.rb', line 26

def initialize(ttfunk_collection)
  @collection = ttfunk_collection
end

Class Method Details

.from_path(path) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/fontist/collection_file.rb', line 8

def from_path(path)
  io = ::File.new(path, "rb")

  yield new(build_collection(io))
ensure
  io.close
end

Instance Method Details

#[](index) ⇒ Object



42
43
44
# File 'lib/fontist/collection_file.rb', line 42

def [](index)
  FontFile.from_collection_index(@collection, index)
end

#countObject



30
31
32
# File 'lib/fontist/collection_file.rb', line 30

def count
  @collection.count
end

#eachObject



34
35
36
37
38
39
40
# File 'lib/fontist/collection_file.rb', line 34

def each
  count.times do |index|
    yield self[index]
  end

  self
end